Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,12 @@ def process_image(image, num_beams=5, min_p=0.0, top_p=1.0):
|
|
36 |
image = image.convert("RGB")
|
37 |
|
38 |
# Prepare inputs for the model
|
39 |
-
inputs = processor(
|
|
|
|
|
|
|
|
|
|
|
40 |
# Move tensors to the appropriate device
|
41 |
inputs = {k: v.to(device) for k, v in inputs.items()}
|
42 |
|
@@ -74,19 +79,32 @@ with gr.Blocks(css=css) as demo:
|
|
74 |
with gr.Row():
|
75 |
with gr.Column():
|
76 |
input_img = gr.Image(label="Input Picture")
|
|
|
77 |
with gr.Column():
|
78 |
output_text = gr.Textbox(label="Output Text")
|
79 |
|
80 |
submit_btn = gr.Button(value="Submit")
|
81 |
|
82 |
num_beams_slider = gr.Slider(
|
83 |
-
minimum=1,
|
|
|
|
|
|
|
|
|
84 |
)
|
85 |
min_p_slider = gr.Slider(
|
86 |
-
minimum=0,
|
|
|
|
|
|
|
|
|
87 |
)
|
88 |
top_p_slider = gr.Slider(
|
89 |
-
minimum=0,
|
|
|
|
|
|
|
|
|
90 |
)
|
91 |
|
92 |
gr.Examples(
|
|
|
36 |
image = image.convert("RGB")
|
37 |
|
38 |
# Prepare inputs for the model
|
39 |
+
inputs = processor(
|
40 |
+
text="<CAPTION>",
|
41 |
+
images=image,
|
42 |
+
return_tensors="pt"
|
43 |
+
)
|
44 |
+
|
45 |
# Move tensors to the appropriate device
|
46 |
inputs = {k: v.to(device) for k, v in inputs.items()}
|
47 |
|
|
|
79 |
with gr.Row():
|
80 |
with gr.Column():
|
81 |
input_img = gr.Image(label="Input Picture")
|
82 |
+
|
83 |
with gr.Column():
|
84 |
output_text = gr.Textbox(label="Output Text")
|
85 |
|
86 |
submit_btn = gr.Button(value="Submit")
|
87 |
|
88 |
num_beams_slider = gr.Slider(
|
89 |
+
minimum=1,
|
90 |
+
maximum=5,
|
91 |
+
step=1,
|
92 |
+
value=5,
|
93 |
+
label="Number of Beams"
|
94 |
)
|
95 |
min_p_slider = gr.Slider(
|
96 |
+
minimum=0,
|
97 |
+
maximum=1,
|
98 |
+
step=0.01,
|
99 |
+
value=0.0,
|
100 |
+
label="Min-P"
|
101 |
)
|
102 |
top_p_slider = gr.Slider(
|
103 |
+
minimum=0,
|
104 |
+
maximum=1,
|
105 |
+
step=0.01,
|
106 |
+
value=1.0,
|
107 |
+
label="Top-P"
|
108 |
)
|
109 |
|
110 |
gr.Examples(
|