Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,17 +23,15 @@ feature_extractor= ViTImageProcessor.from_pretrained(model_path)
|
|
23 |
|
24 |
# Load model
|
25 |
model = VisionEncoderDecoderModel.from_pretrained(model_path)
|
26 |
-
pixel_values = feature_extractor(images=image, return_tensors="pt").pixel_values
|
27 |
-
# use GPT2's eos_token as the pad as well as eos token
|
28 |
|
29 |
|
30 |
|
31 |
def predict(image,max_length=24, num_beams=4):
|
32 |
image = image.convert('RGB')
|
33 |
-
|
34 |
sequences = model.generate(pixel_values, num_beams=4, max_length=25)
|
35 |
captions = tokenizer.batch_decode(sequences, skip_special_tokens=True)
|
36 |
-
|
37 |
|
38 |
|
39 |
# Gradio Interface
|
|
|
23 |
|
24 |
# Load model
|
25 |
model = VisionEncoderDecoderModel.from_pretrained(model_path)
|
|
|
|
|
26 |
|
27 |
|
28 |
|
29 |
def predict(image,max_length=24, num_beams=4):
|
30 |
image = image.convert('RGB')
|
31 |
+
pixel_values = feature_extractor(images=image, return_tensors="pt").pixel_values
|
32 |
sequences = model.generate(pixel_values, num_beams=4, max_length=25)
|
33 |
captions = tokenizer.batch_decode(sequences, skip_special_tokens=True)
|
34 |
+
return captions
|
35 |
|
36 |
|
37 |
# Gradio Interface
|