Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,8 @@ import io
|
|
5 |
import base64 # Adicionando a biblioteca base64 para decodificação
|
6 |
from PIL import Image
|
7 |
import subprocess
|
|
|
|
|
8 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
9 |
|
10 |
# Carregando o modelo e o processador
|
@@ -90,20 +92,20 @@ document.querySelector('button').addEventListener('click', function() {
|
|
90 |
});
|
91 |
"""
|
92 |
|
93 |
-
single_task_list =[
|
94 |
|
95 |
with gr.Blocks(css=css) as demo:
|
96 |
gr.Markdown(DESCRIPTION)
|
97 |
with gr.Tab(label="Product Image Select"):
|
98 |
with gr.Row():
|
99 |
with gr.Column():
|
100 |
-
input_img = gr.Image(label="Input Picture",
|
101 |
task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt", value="Product Caption")
|
102 |
submit_btn = gr.Button(value="Submit")
|
103 |
with gr.Column():
|
104 |
output_text = gr.HTML(label="Output Text", elem_id="output")
|
105 |
|
106 |
-
gr.Markdown("""
|
107 |
## How to use via API
|
108 |
To use this model via API, you can follow the example code below:
|
109 |
|
@@ -126,12 +128,11 @@ with gr.Blocks(css=css) as demo:
|
|
126 |
|
127 |
response = requests.post("http://your-space-url-here", json=payload)
|
128 |
print(response.json())
|
129 |
-
```
|
130 |
-
|
131 |
""")
|
132 |
|
133 |
submit_btn.click(process_image, [input_img, task_prompt], [output_text])
|
134 |
|
135 |
demo.load(lambda: None, inputs=None, outputs=None, js=js)
|
136 |
|
137 |
-
demo.launch(debug=True)
|
|
|
5 |
import base64 # Adicionando a biblioteca base64 para decodificação
|
6 |
from PIL import Image
|
7 |
import subprocess
|
8 |
+
|
9 |
+
# Instalando a dependência flash-attn se necessário
|
10 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
11 |
|
12 |
# Carregando o modelo e o processador
|
|
|
92 |
});
|
93 |
"""
|
94 |
|
95 |
+
single_task_list = ['Product Caption', 'OCR']
|
96 |
|
97 |
with gr.Blocks(css=css) as demo:
|
98 |
gr.Markdown(DESCRIPTION)
|
99 |
with gr.Tab(label="Product Image Select"):
|
100 |
with gr.Row():
|
101 |
with gr.Column():
|
102 |
+
input_img = gr.Image(label="Input Picture", source="upload", type="pil") # Suporte a PIL images
|
103 |
task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt", value="Product Caption")
|
104 |
submit_btn = gr.Button(value="Submit")
|
105 |
with gr.Column():
|
106 |
output_text = gr.HTML(label="Output Text", elem_id="output")
|
107 |
|
108 |
+
gr.Markdown("""
|
109 |
## How to use via API
|
110 |
To use this model via API, you can follow the example code below:
|
111 |
|
|
|
128 |
|
129 |
response = requests.post("http://your-space-url-here", json=payload)
|
130 |
print(response.json())
|
131 |
+
```
|
|
|
132 |
""")
|
133 |
|
134 |
submit_btn.click(process_image, [input_img, task_prompt], [output_text])
|
135 |
|
136 |
demo.load(lambda: None, inputs=None, outputs=None, js=js)
|
137 |
|
138 |
+
demo.launch(debug=True)
|