Spaces:
Runtime error
Runtime error
Update app.py
Browse files24 unmodified lines25262728293031323324 unmodified lines])image_tensor = transform(image).unsqueeze(0).to(device)# Generate caption with the fixed promptinput_text = FIXED_PROMPT + " "output = model.generate(pixel_values=image_tensor, input_text=input_text)caption = tokenizer.decode(output[0], skip_special_tokens=True)return caption24 unmodified lines25262728293031323334353624 unmodified lines])image_tensor = transform(image).unsqueeze(0).to(device)# Prepend the fixed prompt to the input tensorfixed_prompt_tensor = tokenizer(FIXED_PROMPT, return_tensors="pt").input_ids.to(device)input_tensor = torch.cat((fixed_prompt_tensor, image_tensor), dim=1)# Generate captionoutput = model.generate(pixel_values=image_tensor)caption = tokenizer.decode(output[0], skip_special_tokens=True)return caption
app.py+6-3