ValueError: Could not load model microsoft/Florence-2-large with any of the following classes.

#35
by Dhruv - opened

I am loading the transformers pipeline on the google colab with the T4 GPU runtime . the transformers version is 4.41.2 and when I am trying to run the following pipeline command:


# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("image-to-text", model="microsoft/Florence-2-large", trust_remote_code=True)

so I think for now the support to the pipeline should be removed till its being supported .

hi, did you manage to run the model? I cannot even load the model using the example code. I'm using transformers 4.50.0.dev0

'''

device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-large", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-large", trust_remote_code=True)

prompt = ""

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(text=prompt, images=image, return_tensors="pt").to(device, torch_dtype)

generated_ids = model.generate(
input_ids=inputs["input_ids"],
pixel_values=inputs["pixel_values"],
max_new_tokens=4096,
num_beams=3,
do_sample=False
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]

parsed_answer = processor.post_process_generation(generated_text, task="", image_size=(image.width, image.height))

print(parsed_answer)
'''

Sign up or log in to comment