Spaces:
Running
on
Zero
Running
on
Zero
update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ from transformers import AutoModel, AutoTokenizer
|
|
| 4 |
import spaces
|
| 5 |
import os
|
| 6 |
import tempfile
|
|
|
|
| 7 |
|
| 8 |
# Load model and tokenizer
|
| 9 |
model_name = "deepseek-ai/DeepSeek-OCR"
|
|
@@ -151,12 +152,12 @@ with gr.Blocks(title="DeepSeek-OCR", theme=gr.themes.Soft()) as demo:
|
|
| 151 |
|
| 152 |
with gr.Column(scale=2):
|
| 153 |
with gr.Tabs():
|
| 154 |
-
with gr.TabItem("Markdown Output"):
|
| 155 |
-
output_markdown = gr.Markdown(label="Markdown Formatted Result")
|
| 156 |
with gr.TabItem("Annotated Image"):
|
| 157 |
output_image = gr.Image(
|
| 158 |
label="Result with Bounding Boxes", interactive=False
|
| 159 |
)
|
|
|
|
|
|
|
| 160 |
with gr.TabItem("Plain Text (Eval Mode)"):
|
| 161 |
output_text = gr.Textbox(
|
| 162 |
label="OCR Result (eval_mode == True)",
|
|
@@ -169,7 +170,7 @@ with gr.Blocks(title="DeepSeek-OCR", theme=gr.themes.Soft()) as demo:
|
|
| 169 |
gr.Examples(
|
| 170 |
examples=[
|
| 171 |
["examples/math.png", "Gundam (Recommended)", "Convert to Markdown"],
|
| 172 |
-
["examples/receipt.jpg", "Base", "
|
| 173 |
],
|
| 174 |
inputs=[image_input, model_size, task_type],
|
| 175 |
outputs=[output_image, output_markdown, output_text, eval_mode_checkbox],
|
|
|
|
| 4 |
import spaces
|
| 5 |
import os
|
| 6 |
import tempfile
|
| 7 |
+
from PIL import Image
|
| 8 |
|
| 9 |
# Load model and tokenizer
|
| 10 |
model_name = "deepseek-ai/DeepSeek-OCR"
|
|
|
|
| 152 |
|
| 153 |
with gr.Column(scale=2):
|
| 154 |
with gr.Tabs():
|
|
|
|
|
|
|
| 155 |
with gr.TabItem("Annotated Image"):
|
| 156 |
output_image = gr.Image(
|
| 157 |
label="Result with Bounding Boxes", interactive=False
|
| 158 |
)
|
| 159 |
+
with gr.TabItem("Markdown Output"):
|
| 160 |
+
output_markdown = gr.Markdown(label="Markdown Formatted Result")
|
| 161 |
with gr.TabItem("Plain Text (Eval Mode)"):
|
| 162 |
output_text = gr.Textbox(
|
| 163 |
label="OCR Result (eval_mode == True)",
|
|
|
|
| 170 |
gr.Examples(
|
| 171 |
examples=[
|
| 172 |
["examples/math.png", "Gundam (Recommended)", "Convert to Markdown"],
|
| 173 |
+
["examples/receipt.jpg", "Base", "Convert to Markdown"],
|
| 174 |
],
|
| 175 |
inputs=[image_input, model_size, task_type],
|
| 176 |
outputs=[output_image, output_markdown, output_text, eval_mode_checkbox],
|