Closed jrp2014 closed 2 months ago
Hey @jrp2014 @landocoderissian
Sorry I missed it, last week I was moving into a new place :)
Let me check it out and get back to ASAP
@jrp2014 @landocoderissian
The error you are getting it's actually a transformers processor error and not MLX.
It seems like there is something wrong with a image path. Please ensure it's a strings.
I tested it with local files as well and it works fine.
Wait, I found the issue.
Phi-3.5-vision takes a <|image_1|>
instead of <image>
.
Here is the fixed script:
import mlx.core as mx
from mlx_vlm import load, generate
import os
from pathlib import Path
model_path = "mlx-community/Phi-3.5-vision-instruct-bf16"
model, processor = load(model_path)
prompt = processor.tokenizer.apply_chat_template(
[{"role": "user", "content": f"<|image_1|>\nProvide a formal caption and keywords for this image"}],
tokenize=False,
add_generation_prompt=True,
)
picpath = "/Users/jrp/Pictures/Processed"
pics = sorted(Path(picpath).iterdir(), key=os.path.getmtime, reverse=True)
pic = str(pics[0])
output = generate(model, processor, pic, prompt, max_tokens=200, verbose=True)
print(output)
Let me know if this fixes your issue.
For now I will close it.
Running this script:
... all's well with
model_path = "mlx-community/llava-v1.6-mistral-7b-8bit"
, but withmodel_path = "mlx-community/Phi-3.5-vision-instruct-bf16"
I get