Spaces:
Runtime error
Runtime error
Leon Seidel
commited on
Commit
·
84bdadf
1
Parent(s):
d387a30
Use JSON output
Browse files
app.py
CHANGED
@@ -40,17 +40,17 @@ def generate(image):
|
|
40 |
inputs = inputs.to("cuda")
|
41 |
|
42 |
# Inference: Generation of the output
|
43 |
-
generated_ids = model.generate(**inputs, max_new_tokens=
|
44 |
generated_ids_trimmed = [
|
45 |
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
46 |
]
|
47 |
output_text = processor.batch_decode(
|
48 |
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
49 |
)
|
50 |
-
return output_text
|
51 |
|
52 |
inputs = gr.Image(type="pil", label="Input Image")
|
53 |
-
outputs = gr.
|
54 |
|
55 |
demo = gr.Interface(fn=generate, inputs=inputs, outputs=outputs, deep_link=False)
|
56 |
demo.launch()
|
|
|
40 |
inputs = inputs.to("cuda")
|
41 |
|
42 |
# Inference: Generation of the output
|
43 |
+
generated_ids = model.generate(**inputs, max_new_tokens=300)
|
44 |
generated_ids_trimmed = [
|
45 |
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
46 |
]
|
47 |
output_text = processor.batch_decode(
|
48 |
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
49 |
)
|
50 |
+
return output_text[0]
|
51 |
|
52 |
inputs = gr.Image(type="pil", label="Input Image")
|
53 |
+
outputs = gr.JSON(label="Output")
|
54 |
|
55 |
demo = gr.Interface(fn=generate, inputs=inputs, outputs=outputs, deep_link=False)
|
56 |
demo.launch()
|