arinbalyan commited on
Commit
50c7d7f
·
verified ·
1 Parent(s): 42ddc64

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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 processor.decode(idx)
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(theme=theme, css=css, title="Visual Q&A") as demo:
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)