Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -78,16 +78,6 @@ model_x = AutoModelForVision2Seq.from_pretrained(
|
|
78 |
torch_dtype=torch.float16
|
79 |
).to(device).eval()
|
80 |
|
81 |
-
# Load dots.ocr
|
82 |
-
MODEL_ID_D = "rednote-hilab/dots.ocr"
|
83 |
-
processor_d = AutoProcessor.from_pretrained(MODEL_ID_D, trust_remote_code=True)
|
84 |
-
model_d = AutoModelForCausalLM.from_pretrained(
|
85 |
-
MODEL_ID_D,
|
86 |
-
attn_implementation="flash_attention_2",
|
87 |
-
trust_remote_code=True,
|
88 |
-
torch_dtype=torch.float16
|
89 |
-
).to(device).eval()
|
90 |
-
|
91 |
# Preprocessing functions for SmolDocling-256M
|
92 |
def add_random_padding(image, min_percent=0.1, max_percent=0.10):
|
93 |
"""Add random padding to an image based on its size."""
|
@@ -154,9 +144,6 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
154 |
elif model_name == "Typhoon-OCR-7B":
|
155 |
processor = processor_l
|
156 |
model = model_l
|
157 |
-
elif model_name == "rednote-dots.ocr":
|
158 |
-
processor = processor_d
|
159 |
-
model = model_d
|
160 |
else:
|
161 |
yield "Invalid model selected.", "Invalid model selected."
|
162 |
return
|
@@ -235,9 +222,6 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
235 |
elif model_name == "Typhoon-OCR-7B":
|
236 |
processor = processor_l
|
237 |
model = model_l
|
238 |
-
elif model_name == "rednote-dots.ocr":
|
239 |
-
processor = processor_d
|
240 |
-
model = model_d
|
241 |
else:
|
242 |
yield "Invalid model selected.", "Invalid model selected."
|
243 |
return
|
@@ -368,7 +352,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
368 |
formatted_output = gr.Markdown(label="(Result.md)")
|
369 |
|
370 |
model_choice = gr.Radio(
|
371 |
-
choices=["Nanonets-OCR-s", "MonkeyOCR-Recognition", "
|
372 |
label="Select Model",
|
373 |
value="Nanonets-OCR-s"
|
374 |
)
|
|
|
78 |
torch_dtype=torch.float16
|
79 |
).to(device).eval()
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
# Preprocessing functions for SmolDocling-256M
|
82 |
def add_random_padding(image, min_percent=0.1, max_percent=0.10):
|
83 |
"""Add random padding to an image based on its size."""
|
|
|
144 |
elif model_name == "Typhoon-OCR-7B":
|
145 |
processor = processor_l
|
146 |
model = model_l
|
|
|
|
|
|
|
147 |
else:
|
148 |
yield "Invalid model selected.", "Invalid model selected."
|
149 |
return
|
|
|
222 |
elif model_name == "Typhoon-OCR-7B":
|
223 |
processor = processor_l
|
224 |
model = model_l
|
|
|
|
|
|
|
225 |
else:
|
226 |
yield "Invalid model selected.", "Invalid model selected."
|
227 |
return
|
|
|
352 |
formatted_output = gr.Markdown(label="(Result.md)")
|
353 |
|
354 |
model_choice = gr.Radio(
|
355 |
+
choices=["Nanonets-OCR-s", "MonkeyOCR-Recognition", "Typhoon-OCR-7B", "SmolDocling-256M-preview"],
|
356 |
label="Select Model",
|
357 |
value="Nanonets-OCR-s"
|
358 |
)
|