Spaces:
Runtime error
Runtime error
ziqingyang
commited on
Commit
•
5cec2d8
1
Parent(s):
67aa591
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ import os
|
|
36 |
openai.api_key= os.getenv('openai_appkey')
|
37 |
def gpt3_short(question,vqa_answer,caption):
|
38 |
vqa_answer,vqa_score=vqa_answer
|
39 |
-
prompt="prompt: This is
|
40 |
" B: "+vqa_answer[1]+" score:"+str(vqa_score[1])+" C: "+vqa_answer[2]+" score:"+str(vqa_score[2])+\
|
41 |
" D: "+vqa_answer[3]+'score:'+str(vqa_score[3])+\
|
42 |
". Choose A if it is not in conflict with the description of the picture and A's score is bigger than 0.8; otherwise choose the B, C or D based on the description. Answer with A or B or C or D."
|
@@ -98,7 +98,17 @@ def inference_chat(input_image,input_text):
|
|
98 |
gpt3_out=gpt3(input_text,vqa,cap)
|
99 |
gpt3_out1=gpt3_short(input_text,out,cap)
|
100 |
return out[0][0], gpt3_out,gpt3_out1
|
101 |
-
title = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
with gr.Blocks(
|
103 |
css="""
|
104 |
.message.svelte-w6rprc.svelte-w6rprc.svelte-w6rprc {font-size: 20px; margin-top: 20px}
|
@@ -108,7 +118,7 @@ with gr.Blocks(
|
|
108 |
state = gr.State([])
|
109 |
#caption_output = None
|
110 |
gr.Markdown(title)
|
111 |
-
|
112 |
#gr.Markdown(article)
|
113 |
|
114 |
with gr.Row():
|
|
|
36 |
openai.api_key= os.getenv('openai_appkey')
|
37 |
def gpt3_short(question,vqa_answer,caption):
|
38 |
vqa_answer,vqa_score=vqa_answer
|
39 |
+
prompt="prompt: This is the caption of a picture: "+caption+". Question: "+question+" VQA model predicts:"+"A: "+vqa_answer[0]+"socre:"+str(vqa_score[0])+\
|
40 |
" B: "+vqa_answer[1]+" score:"+str(vqa_score[1])+" C: "+vqa_answer[2]+" score:"+str(vqa_score[2])+\
|
41 |
" D: "+vqa_answer[3]+'score:'+str(vqa_score[3])+\
|
42 |
". Choose A if it is not in conflict with the description of the picture and A's score is bigger than 0.8; otherwise choose the B, C or D based on the description. Answer with A or B or C or D."
|
|
|
98 |
gpt3_out=gpt3(input_text,vqa,cap)
|
99 |
gpt3_out1=gpt3_short(input_text,out,cap)
|
100 |
return out[0][0], gpt3_out,gpt3_out1
|
101 |
+
title = """# VQA with VLE and LLM"""
|
102 |
+
description = """We demonstrate three visual question answering systems built with VLE and LLM:
|
103 |
+
|
104 |
+
* VQA: The image and the question are fed into a VQA model (VLEForVQA) and the model predicts the answer.
|
105 |
+
|
106 |
+
* VQA + LLM (short answer): The captioning model generates a caption of the image. We feed the caption, the question, and the answer candidates predicted by the VQA model to the LLM, and ask the LLM to select the most reasonable answer from the candidates.
|
107 |
+
|
108 |
+
* VQA + LLM (long answer): The pipeline is the same as VQA + LLM (short answer), except that the answer is freely generated by the LLM and not limited to VQA candidates.
|
109 |
+
|
110 |
+
For more details about VLE and the VQA pipeline, see [http://vle.hfl-rc.com](http://vle.hfl-rc.com)"""
|
111 |
+
|
112 |
with gr.Blocks(
|
113 |
css="""
|
114 |
.message.svelte-w6rprc.svelte-w6rprc.svelte-w6rprc {font-size: 20px; margin-top: 20px}
|
|
|
118 |
state = gr.State([])
|
119 |
#caption_output = None
|
120 |
gr.Markdown(title)
|
121 |
+
gr.Markdown(description)
|
122 |
#gr.Markdown(article)
|
123 |
|
124 |
with gr.Row():
|