Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,11 +21,11 @@ model = AutoModel.from_pretrained(MODEL_NAME, _attn_implementation='flash_attent
|
|
| 21 |
model = model.eval().cuda()
|
| 22 |
|
| 23 |
MODEL_CONFIGS = {
|
| 24 |
-
"
|
| 25 |
-
"
|
| 26 |
-
"
|
| 27 |
-
"
|
| 28 |
-
"
|
| 29 |
}
|
| 30 |
|
| 31 |
TASK_PROMPTS = {
|
|
@@ -230,7 +230,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="DeepSeek-OCR") as demo:
|
|
| 230 |
with gr.Column(scale=1):
|
| 231 |
file_in = gr.File(label="Upload Image or PDF", file_types=["image", ".pdf"], type="filepath")
|
| 232 |
input_img = gr.Image(label="Input Image", type="pil", height=300)
|
| 233 |
-
mode = gr.Dropdown(list(MODEL_CONFIGS.keys()), value="
|
| 234 |
task = gr.Dropdown(list(TASK_PROMPTS.keys()), value="π Markdown", label="Task")
|
| 235 |
prompt = gr.Textbox(label="Prompt", lines=2, visible=False)
|
| 236 |
btn = gr.Button("Extract", variant="primary", size="lg")
|
|
@@ -250,8 +250,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="DeepSeek-OCR") as demo:
|
|
| 250 |
|
| 251 |
gr.Examples(
|
| 252 |
examples=[
|
| 253 |
-
["examples/ocr.jpg", "
|
| 254 |
-
["examples/reachy-mini.jpg", "
|
| 255 |
],
|
| 256 |
inputs=[input_img, mode, task, prompt],
|
| 257 |
cache_examples=False
|
|
@@ -269,7 +269,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="DeepSeek-OCR") as demo:
|
|
| 269 |
### Tasks
|
| 270 |
- **Markdown**: Convert document to structured markdown (grounding β
)
|
| 271 |
- **Free OCR**: Simple text extraction
|
| 272 |
-
- **Locate**: Find specific
|
| 273 |
- **Describe**: General image description
|
| 274 |
- **Custom**: Your own prompt (add `<|grounding|>` for boxes)
|
| 275 |
""")
|
|
|
|
| 21 |
model = model.eval().cuda()
|
| 22 |
|
| 23 |
MODEL_CONFIGS = {
|
| 24 |
+
"Gundam": {"base_size": 1024, "image_size": 640, "crop_mode": True},
|
| 25 |
+
"Tiny": {"base_size": 512, "image_size": 512, "crop_mode": False},
|
| 26 |
+
"Small": {"base_size": 640, "image_size": 640, "crop_mode": False},
|
| 27 |
+
"Base": {"base_size": 1024, "image_size": 1024, "crop_mode": False},
|
| 28 |
+
"Large": {"base_size": 1280, "image_size": 1280, "crop_mode": False}
|
| 29 |
}
|
| 30 |
|
| 31 |
TASK_PROMPTS = {
|
|
|
|
| 230 |
with gr.Column(scale=1):
|
| 231 |
file_in = gr.File(label="Upload Image or PDF", file_types=["image", ".pdf"], type="filepath")
|
| 232 |
input_img = gr.Image(label="Input Image", type="pil", height=300)
|
| 233 |
+
mode = gr.Dropdown(list(MODEL_CONFIGS.keys()), value="Gundam", label="Mode")
|
| 234 |
task = gr.Dropdown(list(TASK_PROMPTS.keys()), value="π Markdown", label="Task")
|
| 235 |
prompt = gr.Textbox(label="Prompt", lines=2, visible=False)
|
| 236 |
btn = gr.Button("Extract", variant="primary", size="lg")
|
|
|
|
| 250 |
|
| 251 |
gr.Examples(
|
| 252 |
examples=[
|
| 253 |
+
["examples/ocr.jpg", "Gundam", "π Markdown", ""],
|
| 254 |
+
["examples/reachy-mini.jpg", "Gundam", "π Locate", "Robot"]
|
| 255 |
],
|
| 256 |
inputs=[input_img, mode, task, prompt],
|
| 257 |
cache_examples=False
|
|
|
|
| 269 |
### Tasks
|
| 270 |
- **Markdown**: Convert document to structured markdown (grounding β
)
|
| 271 |
- **Free OCR**: Simple text extraction
|
| 272 |
+
- **Locate**: Find specific things in image (grounding β
)
|
| 273 |
- **Describe**: General image description
|
| 274 |
- **Custom**: Your own prompt (add `<|grounding|>` for boxes)
|
| 275 |
""")
|