Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,15 +29,6 @@ MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
|
| 29 |
|
| 30 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 31 |
|
| 32 |
-
# Load VIREX-062225-exp
|
| 33 |
-
MODEL_ID_M = "prithivMLmods/VIREX-062225-exp"
|
| 34 |
-
processor_m = AutoProcessor.from_pretrained(MODEL_ID_M, trust_remote_code=True)
|
| 35 |
-
model_m = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 36 |
-
MODEL_ID_M,
|
| 37 |
-
trust_remote_code=True,
|
| 38 |
-
torch_dtype=torch.float16
|
| 39 |
-
).to(device).eval()
|
| 40 |
-
|
| 41 |
# Load DREX-062225-exp
|
| 42 |
MODEL_ID_X = "prithivMLmods/DREX-062225-exp"
|
| 43 |
processor_x = AutoProcessor.from_pretrained(MODEL_ID_X, trust_remote_code=True)
|
|
@@ -105,10 +96,7 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
| 105 |
"""
|
| 106 |
Generates responses using the selected model for image input.
|
| 107 |
"""
|
| 108 |
-
if model_name == "
|
| 109 |
-
processor = processor_m
|
| 110 |
-
model = model_m
|
| 111 |
-
elif model_name == "DREX-062225-7B-exp":
|
| 112 |
processor = processor_x
|
| 113 |
model = model_x
|
| 114 |
elif model_name == "olmOCR-7B-0225-preview":
|
|
@@ -164,10 +152,7 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
| 164 |
"""
|
| 165 |
Generates responses using the selected model for video input.
|
| 166 |
"""
|
| 167 |
-
if model_name == "
|
| 168 |
-
processor = processor_m
|
| 169 |
-
model = model_m
|
| 170 |
-
elif model_name == "DREX-062225-7B-exp":
|
| 171 |
processor = processor_x
|
| 172 |
model = model_x
|
| 173 |
elif model_name == "olmOCR-7B-0225-preview":
|
|
@@ -303,7 +288,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 303 |
#download_btn = gr.Button("Download Result.md"
|
| 304 |
|
| 305 |
model_choice = gr.Radio(
|
| 306 |
-
choices=["DREX-062225-7B-exp", "Megalodon-OCR", "olmOCR-7B-0225-preview", "
|
| 307 |
label="Select Model",
|
| 308 |
value="DREX-062225-7B-exp"
|
| 309 |
)
|
|
@@ -311,7 +296,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 311 |
gr.Markdown("**Model Info 💻** | [Report Bug](https://huggingface.co/spaces/prithivMLmods/Doc-VLMs/discussions)")
|
| 312 |
gr.Markdown("> [DREX-062225-7B-exp](https://huggingface.co/prithivMLmods/DREX-062225-exp): the drex-062225-exp (document retrieval and extraction expert) model is a specialized fine-tuned version of docscopeocr-7b-050425-exp, optimized for document retrieval, content extraction, and analysis recognition. built on top of the qwen2.5-vl architecture.")
|
| 313 |
gr.Markdown("> [Megalodon-OCR-Sync-0713](https://huggingface.co/prithivMLmods/Megalodon-OCR-Sync-0713): megalodon-ocr-sync-0713 model is a fine-tuned version of qwen2.5-vl-3b-instruct, optimized for document retrieval, content extraction, and analysis recognition. built on top of the qwen2.5-vl architecture, this model enhances document comprehension capabilities.")
|
| 314 |
-
gr.Markdown("> [VIREX-062225-7B-exp](https://huggingface.co/prithivMLmods/VIREX-062225-exp): the virex-062225-exp (video information retrieval and extraction expert - experimental) model is a fine-tuned version of qwen2.5-vl-7b-instruct, specifically optimized for advanced video understanding, image comprehension, sense of reasoning, and natural language decision-making through cot reasoning.")
|
| 315 |
gr.Markdown("> [Typhoon-OCR-3B](https://huggingface.co/scb10x/typhoon-ocr-3b): a bilingual document parsing model built specifically for real-world documents in thai and english, inspired by models like olmocr, based on qwen2.5-vl-instruction. this model is intended to be used with a specific prompt only.")
|
| 316 |
gr.Markdown("> [olmOCR-7B-0225](https://huggingface.co/allenai/olmOCR-7B-0225-preview): the olmocr-7b-0225-preview model is based on qwen2-vl-7b, optimized for document-level optical character recognition (ocr), long-context vision-language understanding, and accurate image-to-text conversion with mathematical latex formatting. designed with a focus on high-fidelity visual-textual comprehension.")
|
| 317 |
gr.Markdown(">⚠️note: all the models in space are not guaranteed to perform well in video inference use cases.")
|
|
|
|
| 29 |
|
| 30 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# Load DREX-062225-exp
|
| 33 |
MODEL_ID_X = "prithivMLmods/DREX-062225-exp"
|
| 34 |
processor_x = AutoProcessor.from_pretrained(MODEL_ID_X, trust_remote_code=True)
|
|
|
|
| 96 |
"""
|
| 97 |
Generates responses using the selected model for image input.
|
| 98 |
"""
|
| 99 |
+
if model_name == "DREX-062225-7B-exp":
|
|
|
|
|
|
|
|
|
|
| 100 |
processor = processor_x
|
| 101 |
model = model_x
|
| 102 |
elif model_name == "olmOCR-7B-0225-preview":
|
|
|
|
| 152 |
"""
|
| 153 |
Generates responses using the selected model for video input.
|
| 154 |
"""
|
| 155 |
+
if model_name == "DREX-062225-7B-exp":
|
|
|
|
|
|
|
|
|
|
| 156 |
processor = processor_x
|
| 157 |
model = model_x
|
| 158 |
elif model_name == "olmOCR-7B-0225-preview":
|
|
|
|
| 288 |
#download_btn = gr.Button("Download Result.md"
|
| 289 |
|
| 290 |
model_choice = gr.Radio(
|
| 291 |
+
choices=["DREX-062225-7B-exp", "Megalodon-OCR", "olmOCR-7B-0225-preview", "Typhoon-OCR-3B"],
|
| 292 |
label="Select Model",
|
| 293 |
value="DREX-062225-7B-exp"
|
| 294 |
)
|
|
|
|
| 296 |
gr.Markdown("**Model Info 💻** | [Report Bug](https://huggingface.co/spaces/prithivMLmods/Doc-VLMs/discussions)")
|
| 297 |
gr.Markdown("> [DREX-062225-7B-exp](https://huggingface.co/prithivMLmods/DREX-062225-exp): the drex-062225-exp (document retrieval and extraction expert) model is a specialized fine-tuned version of docscopeocr-7b-050425-exp, optimized for document retrieval, content extraction, and analysis recognition. built on top of the qwen2.5-vl architecture.")
|
| 298 |
gr.Markdown("> [Megalodon-OCR-Sync-0713](https://huggingface.co/prithivMLmods/Megalodon-OCR-Sync-0713): megalodon-ocr-sync-0713 model is a fine-tuned version of qwen2.5-vl-3b-instruct, optimized for document retrieval, content extraction, and analysis recognition. built on top of the qwen2.5-vl architecture, this model enhances document comprehension capabilities.")
|
|
|
|
| 299 |
gr.Markdown("> [Typhoon-OCR-3B](https://huggingface.co/scb10x/typhoon-ocr-3b): a bilingual document parsing model built specifically for real-world documents in thai and english, inspired by models like olmocr, based on qwen2.5-vl-instruction. this model is intended to be used with a specific prompt only.")
|
| 300 |
gr.Markdown("> [olmOCR-7B-0225](https://huggingface.co/allenai/olmOCR-7B-0225-preview): the olmocr-7b-0225-preview model is based on qwen2-vl-7b, optimized for document-level optical character recognition (ocr), long-context vision-language understanding, and accurate image-to-text conversion with mathematical latex formatting. designed with a focus on high-fidelity visual-textual comprehension.")
|
| 301 |
gr.Markdown(">⚠️note: all the models in space are not guaranteed to perform well in video inference use cases.")
|