Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,8 @@ processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-capfilt-large")
|
|
12 |
model_vqa = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-capfilt-large").to(device)
|
13 |
def inference_chat(input_image,input_text):
|
14 |
inputs = processor(images=input_image, text=input_text,return_tensors="pt")
|
15 |
-
|
16 |
-
|
17 |
inputs["max_length"] = 20
|
18 |
inputs["num_beams"] = 5
|
19 |
-
|
20 |
out = model_vqa.generate(**inputs)
|
21 |
return processor.batch_decode(out, skip_special_tokens=True)[0]
|
22 |
|
@@ -39,8 +36,8 @@ with gr.Blocks(
|
|
39 |
with gr.Row():
|
40 |
|
41 |
with gr.Column(scale=1):
|
42 |
-
caption_output = gr.Textbox(lines=0, label="")
|
43 |
-
chat_input = gr.Textbox(lines=1, label="VQA Input")
|
44 |
chat_input.submit(
|
45 |
inference_chat,
|
46 |
[
|
@@ -70,7 +67,6 @@ with gr.Blocks(
|
|
70 |
],
|
71 |
[caption_output],
|
72 |
)
|
73 |
-
caption_output = gr.Textbox(lines=1, label="VQA Output")
|
74 |
|
75 |
|
76 |
image_input.change(
|
|
|
12 |
model_vqa = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-capfilt-large").to(device)
|
13 |
def inference_chat(input_image,input_text):
|
14 |
inputs = processor(images=input_image, text=input_text,return_tensors="pt")
|
|
|
|
|
15 |
inputs["max_length"] = 20
|
16 |
inputs["num_beams"] = 5
|
|
|
17 |
out = model_vqa.generate(**inputs)
|
18 |
return processor.batch_decode(out, skip_special_tokens=True)[0]
|
19 |
|
|
|
36 |
with gr.Row():
|
37 |
|
38 |
with gr.Column(scale=1):
|
39 |
+
caption_output = gr.Textbox(lines=0, label="VQA Output(模型答案输出)")
|
40 |
+
chat_input = gr.Textbox(lines=1, label="VQA Input(问题输入)")
|
41 |
chat_input.submit(
|
42 |
inference_chat,
|
43 |
[
|
|
|
67 |
],
|
68 |
[caption_output],
|
69 |
)
|
|
|
70 |
|
71 |
|
72 |
image_input.change(
|