Update app.py
Browse files
app.py
CHANGED
|
@@ -32,14 +32,13 @@ def run_example(task_prompt, image):
|
|
| 32 |
)
|
| 33 |
return parsed_answer
|
| 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 |
-
|
| 43 |
results = run_example(task_prompt, image)
|
| 44 |
|
| 45 |
# Remove the key and get the text value
|
|
@@ -76,9 +75,11 @@ document.querySelector('button').addEventListener('click', function() {
|
|
| 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"):
|
|
@@ -107,7 +108,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 107 |
```
|
| 108 |
""")
|
| 109 |
|
| 110 |
-
submit_btn.click(process_image, [input_img], [output_text])
|
| 111 |
|
| 112 |
demo.load(lambda: None, inputs=None, outputs=None, js=js)
|
| 113 |
|
|
|
|
| 32 |
)
|
| 33 |
return parsed_answer
|
| 34 |
|
| 35 |
+
def process_image(image, task_prompt):
|
| 36 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
| 37 |
if task_prompt == 'Product Caption':
|
| 38 |
task_prompt = '<PC>'
|
|
|
|
| 39 |
elif task_prompt == 'OCR':
|
| 40 |
task_prompt = '<OCR>'
|
| 41 |
+
|
| 42 |
results = run_example(task_prompt, image)
|
| 43 |
|
| 44 |
# Remove the key and get the text value
|
|
|
|
| 75 |
setTimeout(adjustHeight, 500); // Adjust the height after a small delay to ensure content is loaded
|
| 76 |
});
|
| 77 |
"""
|
| 78 |
+
|
| 79 |
single_task_list =[
|
| 80 |
'Product Caption', 'OCR'
|
| 81 |
]
|
| 82 |
+
|
| 83 |
with gr.Blocks(css=css) as demo:
|
| 84 |
gr.Markdown(DESCRIPTION)
|
| 85 |
with gr.Tab(label="Product Image Select"):
|
|
|
|
| 108 |
```
|
| 109 |
""")
|
| 110 |
|
| 111 |
+
submit_btn.click(process_image, [input_img, task_prompt], [output_text])
|
| 112 |
|
| 113 |
demo.load(lambda: None, inputs=None, outputs=None, js=js)
|
| 114 |
|