Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,12 @@ def run_example(task_prompt, image):
|
|
34 |
|
35 |
def process_image(image):
|
36 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
37 |
-
task_prompt
|
|
|
|
|
|
|
|
|
|
|
38 |
results = run_example(task_prompt, image)
|
39 |
|
40 |
# Remove the key and get the text value
|
@@ -71,13 +76,16 @@ document.querySelector('button').addEventListener('click', function() {
|
|
71 |
setTimeout(adjustHeight, 500); // Adjust the height after a small delay to ensure content is loaded
|
72 |
});
|
73 |
"""
|
74 |
-
|
|
|
|
|
75 |
with gr.Blocks(css=css) as demo:
|
76 |
gr.Markdown(DESCRIPTION)
|
77 |
with gr.Tab(label="Product Image Select"):
|
78 |
with gr.Row():
|
79 |
with gr.Column():
|
80 |
input_img = gr.Image(label="Input Picture")
|
|
|
81 |
submit_btn = gr.Button(value="Submit")
|
82 |
with gr.Column():
|
83 |
output_text = gr.HTML(label="Output Text", elem_id="output")
|
|
|
34 |
|
35 |
def process_image(image):
|
36 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
37 |
+
if task_prompt == 'Product Caption':
|
38 |
+
task_prompt = '<PC>'
|
39 |
+
results = run_example(task_prompt, image, model_id=model_id)
|
40 |
+
elif task_prompt == 'OCR':
|
41 |
+
task_prompt = '<OCR>'
|
42 |
+
results = run_example(task_prompt, image, model_id=model_id)
|
43 |
results = run_example(task_prompt, image)
|
44 |
|
45 |
# Remove the key and get the text value
|
|
|
76 |
setTimeout(adjustHeight, 500); // Adjust the height after a small delay to ensure content is loaded
|
77 |
});
|
78 |
"""
|
79 |
+
single_task_list =[
|
80 |
+
'Product Caption', 'OCR'
|
81 |
+
]
|
82 |
with gr.Blocks(css=css) as demo:
|
83 |
gr.Markdown(DESCRIPTION)
|
84 |
with gr.Tab(label="Product Image Select"):
|
85 |
with gr.Row():
|
86 |
with gr.Column():
|
87 |
input_img = gr.Image(label="Input Picture")
|
88 |
+
task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt", value="Product Caption")
|
89 |
submit_btn = gr.Button(value="Submit")
|
90 |
with gr.Column():
|
91 |
output_text = gr.HTML(label="Output Text", elem_id="output")
|