Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,25 +50,12 @@ def caption_random_image():
|
|
| 50 |
demo = gr.Interface(
|
| 51 |
fn=caption_random_image,
|
| 52 |
inputs=None,
|
| 53 |
-
outputs=["
|
| 54 |
-
title="Image Captioning",
|
| 55 |
-
description="
|
| 56 |
)
|
| 57 |
|
| 58 |
|
| 59 |
-
# conditional image captioning
|
| 60 |
-
text = "a photography of"
|
| 61 |
-
inputs = processor(image, text, return_tensors="pt")
|
| 62 |
-
|
| 63 |
-
out = model.generate(**inputs)
|
| 64 |
-
print(processor.decode(out[0], skip_special_tokens=True))
|
| 65 |
-
|
| 66 |
-
# unconditional image captioning
|
| 67 |
-
inputs = processor(image, return_tensors="pt")
|
| 68 |
-
|
| 69 |
-
out = model.generate(**inputs)
|
| 70 |
-
print(processor.decode(out[0], skip_special_tokens=True))
|
| 71 |
-
|
| 72 |
|
| 73 |
demo.launch()
|
| 74 |
|
|
|
|
| 50 |
demo = gr.Interface(
|
| 51 |
fn=caption_random_image,
|
| 52 |
inputs=None,
|
| 53 |
+
outputs=[gr.Image(type="pil"), gr.Textbox(label="Caption")],
|
| 54 |
+
title="Random COCO Image Captioning",
|
| 55 |
+
description="Selects a random COCO image from 20 samples and generates a BLIP caption."
|
| 56 |
)
|
| 57 |
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
demo.launch()
|
| 61 |
|