Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ def answer_question(image, question):
|
|
| 28 |
encoding = processor(pil_image, question, return_tensors="pt")
|
| 29 |
outputs = model(**encoding)
|
| 30 |
idx = outputs.logits.argmax(-1).item()
|
| 31 |
-
return
|
| 32 |
|
| 33 |
css = """
|
| 34 |
.gradio-container {
|
|
@@ -54,7 +54,7 @@ css = """
|
|
| 54 |
.footer { text-align: center; padding: 1.5rem; color: #64748b; font-size: 0.875rem; }
|
| 55 |
"""
|
| 56 |
|
| 57 |
-
with gr.Blocks(
|
| 58 |
with gr.Row():
|
| 59 |
with gr.Column():
|
| 60 |
gr.HTML("""
|
|
@@ -123,4 +123,4 @@ with gr.Blocks(theme=theme, css=css, title="Visual Q&A") as demo:
|
|
| 123 |
)
|
| 124 |
|
| 125 |
if __name__ == "__main__":
|
| 126 |
-
demo.launch(theme=theme)
|
|
|
|
| 28 |
encoding = processor(pil_image, question, return_tensors="pt")
|
| 29 |
outputs = model(**encoding)
|
| 30 |
idx = outputs.logits.argmax(-1).item()
|
| 31 |
+
return model.config.id2label[idx]
|
| 32 |
|
| 33 |
css = """
|
| 34 |
.gradio-container {
|
|
|
|
| 54 |
.footer { text-align: center; padding: 1.5rem; color: #64748b; font-size: 0.875rem; }
|
| 55 |
"""
|
| 56 |
|
| 57 |
+
with gr.Blocks(title="Visual Q&A") as demo:
|
| 58 |
with gr.Row():
|
| 59 |
with gr.Column():
|
| 60 |
gr.HTML("""
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
if __name__ == "__main__":
|
| 126 |
+
demo.launch(theme=theme, css=css)
|