Update app.py
Browse files
app.py
CHANGED
@@ -50,16 +50,10 @@ def process_image(image):
|
|
50 |
)
|
51 |
|
52 |
# Decode and post-process the generated text
|
53 |
-
|
54 |
generated_ids,
|
55 |
skip_special_tokens=False
|
56 |
-
)[0]
|
57 |
-
caption = processor.post_process_generation(
|
58 |
-
generated_text,
|
59 |
-
task="<CAPTION>",
|
60 |
-
image_size=(image.width, image.height)
|
61 |
-
)
|
62 |
-
return caption
|
63 |
|
64 |
except Exception as e:
|
65 |
return f"Error processing image: {e}"
|
|
|
50 |
)
|
51 |
|
52 |
# Decode and post-process the generated text
|
53 |
+
return processor.batch_decode(
|
54 |
generated_ids,
|
55 |
skip_special_tokens=False
|
56 |
+
)[0].replace('</s>', '').replace('<s>', '').replace('<pad>', '').strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
except Exception as e:
|
59 |
return f"Error processing image: {e}"
|