jpjpjpjpjp commited on
Commit
05ef389
1 Parent(s): 725eef9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -24,11 +24,9 @@ def analyze_image(image, question):
24
  headers = {'Content-Type': 'application/json'}
25
 
26
  response = requests.request("POST", url, headers=headers, data=payload)
27
- '''{"body": [{"doc": "/home/ubuntu/work/4187f911-c1fd-407c-a06b-bc6a0cc74cbe/1.png", "result": [{"question": "invoice date?", "answer": ["01 / 29 / 2010"], "start": 43, "end": 47, "score": 100.0}]}], "starttime": "Thu Mar 9 10:58:07 2023", "endtime": "Thu Mar 9 10:58:12 2023"}'''
28
- print(response)
29
- print(json.loads(response.text)['body'][0]['result'][0]['answer'])
30
  jsonresponse = json.loads(response.text)
31
- return {"Answer": jsonresponse['body'][0]['result'][0]['answer'], "Confidence":jsonresponse['body'][0]['result'][0]['score']}
32
 
33
  description = "Hyland Demo for Document Question & Answering , fine-tuned on DocVQA (document visual question answering). To use it, simply upload your image and type a question and click 'submit', or click one of the examples to load them. Read more at the links below."
34
  title = "DocVQA"
 
24
  headers = {'Content-Type': 'application/json'}
25
 
26
  response = requests.request("POST", url, headers=headers, data=payload)
27
+
 
 
28
  jsonresponse = json.loads(response.text)
29
+ return "Answer: {0} \n Confidence: {1}".format(jsonresponse['body'][0]['result'][0]['answer'][0], jsonresponse['body'][0]['result'][0]['score'])
30
 
31
  description = "Hyland Demo for Document Question & Answering , fine-tuned on DocVQA (document visual question answering). To use it, simply upload your image and type a question and click 'submit', or click one of the examples to load them. Read more at the links below."
32
  title = "DocVQA"