Spaces:
Runtime error
Runtime error
chats-bug
commited on
Commit
·
2e7d5a4
1
Parent(s):
cab88d3
Concatenated captions
Browse files
app.py
CHANGED
@@ -32,6 +32,8 @@ def generate_captions(
|
|
32 |
model = GitBaseCocoModel(device, checkpoint)
|
33 |
|
34 |
caption = model.generate(image, max_len, num_captions)
|
|
|
|
|
35 |
return caption
|
36 |
|
37 |
|
@@ -41,16 +43,21 @@ inputs = [
|
|
41 |
gr.inputs.Number(default=1, label="Number of Captions to Generate"),
|
42 |
]
|
43 |
# Determine the number of outputs based on the number of captions to generate.
|
44 |
-
outputs =
|
45 |
|
46 |
title = "Git-Base-COCO Image Captioning"
|
47 |
description = "A model for generating captions for images."
|
48 |
|
49 |
-
gr.Interface(
|
50 |
fn=generate_captions,
|
51 |
inputs=inputs,
|
52 |
outputs=outputs,
|
53 |
title=title,
|
54 |
description=description,
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
32 |
model = GitBaseCocoModel(device, checkpoint)
|
33 |
|
34 |
caption = model.generate(image, max_len, num_captions)
|
35 |
+
# Convert list to a single string separated by newlines.
|
36 |
+
caption = "\n".join(caption)
|
37 |
return caption
|
38 |
|
39 |
|
|
|
43 |
gr.inputs.Number(default=1, label="Number of Captions to Generate"),
|
44 |
]
|
45 |
# Determine the number of outputs based on the number of captions to generate.
|
46 |
+
outputs = gr.outputs.Textbox(label="Captions")
|
47 |
|
48 |
title = "Git-Base-COCO Image Captioning"
|
49 |
description = "A model for generating captions for images."
|
50 |
|
51 |
+
interface = gr.Interface(
|
52 |
fn=generate_captions,
|
53 |
inputs=inputs,
|
54 |
outputs=outputs,
|
55 |
title=title,
|
56 |
description=description,
|
57 |
+
)
|
58 |
+
|
59 |
+
|
60 |
+
if __name__ == "__main__":
|
61 |
+
interface.launch(
|
62 |
+
enable_queue=True,
|
63 |
+
)
|