Spaces:
Running
on
Zero
Running
on
Zero
update app
Browse files
app.py
CHANGED
|
@@ -107,7 +107,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
|
| 107 |
|
| 108 |
model = AutoModel.from_pretrained(
|
| 109 |
model_name,
|
| 110 |
-
|
| 111 |
trust_remote_code=True,
|
| 112 |
use_safetensors=True,
|
| 113 |
).to(device).eval() # Move to device and set to eval mode
|
|
@@ -211,7 +211,7 @@ def process_ocr_task(image, model_size, task_type, ref_text):
|
|
| 211 |
with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
| 212 |
gr.Markdown("# **DeepSeek OCR [exp]**", elem_id="main-title")
|
| 213 |
|
| 214 |
-
|
| 215 |
with gr.Row():
|
| 216 |
with gr.Column(scale=1):
|
| 217 |
image_input = gr.Image(type="pil", label="Upload Image", sources=["upload", "clipboard"])
|
|
@@ -223,10 +223,10 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
|
| 223 |
with gr.Column(scale=2):
|
| 224 |
output_text = gr.Textbox(label="Output (OCR)", lines=8, show_copy_button=True)
|
| 225 |
output_image = gr.Image(label="Layout Detection (If Any)", type="pil")
|
| 226 |
-
|
| 227 |
with gr.Accordion("Note", open=False):
|
| 228 |
gr.Markdown("Inference using Huggingface transformers on NVIDIA GPUs. This app is running with transformers version 4.57.1 and torch version 2.6.0.")
|
| 229 |
-
|
| 230 |
def toggle_ref_text_visibility(task):
|
| 231 |
return gr.Textbox(visible=True) if task == "Locate Object by Reference" else gr.Textbox(visible=False)
|
| 232 |
|
|
@@ -234,4 +234,4 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
|
| 234 |
submit_btn.click(fn=process_ocr_task, inputs=[image_input, model_size, task_type, ref_text_input], outputs=[output_text, output_image])
|
| 235 |
|
| 236 |
if __name__ == "__main__":
|
| 237 |
-
demo.queue(max_size=20).launch(share=True)
|
|
|
|
| 107 |
|
| 108 |
model = AutoModel.from_pretrained(
|
| 109 |
model_name,
|
| 110 |
+
_attn_implementation="flash_attention_2",
|
| 111 |
trust_remote_code=True,
|
| 112 |
use_safetensors=True,
|
| 113 |
).to(device).eval() # Move to device and set to eval mode
|
|
|
|
| 211 |
with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
| 212 |
gr.Markdown("# **DeepSeek OCR [exp]**", elem_id="main-title")
|
| 213 |
|
| 214 |
+
|
| 215 |
with gr.Row():
|
| 216 |
with gr.Column(scale=1):
|
| 217 |
image_input = gr.Image(type="pil", label="Upload Image", sources=["upload", "clipboard"])
|
|
|
|
| 223 |
with gr.Column(scale=2):
|
| 224 |
output_text = gr.Textbox(label="Output (OCR)", lines=8, show_copy_button=True)
|
| 225 |
output_image = gr.Image(label="Layout Detection (If Any)", type="pil")
|
| 226 |
+
|
| 227 |
with gr.Accordion("Note", open=False):
|
| 228 |
gr.Markdown("Inference using Huggingface transformers on NVIDIA GPUs. This app is running with transformers version 4.57.1 and torch version 2.6.0.")
|
| 229 |
+
|
| 230 |
def toggle_ref_text_visibility(task):
|
| 231 |
return gr.Textbox(visible=True) if task == "Locate Object by Reference" else gr.Textbox(visible=False)
|
| 232 |
|
|
|
|
| 234 |
submit_btn.click(fn=process_ocr_task, inputs=[image_input, model_size, task_type, ref_text_input], outputs=[output_text, output_image])
|
| 235 |
|
| 236 |
if __name__ == "__main__":
|
| 237 |
+
demo.queue(max_size=20).launch(share=True, mcp_server=True, ssr_mode=False)
|