Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,7 +46,7 @@ model_x = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
| 46 |
).to(device).eval()
|
| 47 |
|
| 48 |
# Load Relaxed
|
| 49 |
-
MODEL_ID_Z = "
|
| 50 |
processor_z = AutoProcessor.from_pretrained(MODEL_ID_Z, trust_remote_code=True)
|
| 51 |
model_z = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 52 |
MODEL_ID_Z,
|
|
@@ -54,15 +54,6 @@ model_z = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
| 54 |
torch_dtype=torch.float16
|
| 55 |
).to(device).eval()
|
| 56 |
|
| 57 |
-
# Load Mimo
|
| 58 |
-
MODEL_ID_Mimo = "XiaomiMiMo/MiMo-VL-7B-RL"
|
| 59 |
-
processor_Mimo = AutoProcessor.from_pretrained(MODEL_ID_Mimo, trust_remote_code=True)
|
| 60 |
-
model_Mimo = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 61 |
-
MODEL_ID_Mimo,
|
| 62 |
-
trust_remote_code=True,
|
| 63 |
-
torch_dtype=torch.float16
|
| 64 |
-
).to(device).eval()
|
| 65 |
-
|
| 66 |
def downsample_video(video_path):
|
| 67 |
"""
|
| 68 |
Downsamples the video to evenly spaced frames.
|
|
@@ -103,9 +94,6 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
| 103 |
elif model_name == "Captioner-7B":
|
| 104 |
processor = processor_z
|
| 105 |
model = model_z
|
| 106 |
-
elif model_name == "Mimo-7B-RL":
|
| 107 |
-
processor = processor_Mimo
|
| 108 |
-
model = model_Mimo
|
| 109 |
else:
|
| 110 |
yield "Invalid model selected."
|
| 111 |
return
|
|
@@ -159,9 +147,6 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
| 159 |
elif model_name == "Captioner-7B":
|
| 160 |
processor = processor_z
|
| 161 |
model = model_z
|
| 162 |
-
elif model_name == "Mimo-7B-RL":
|
| 163 |
-
processor = processor_Mimo
|
| 164 |
-
model = model_Mimo
|
| 165 |
else:
|
| 166 |
yield "Invalid model selected."
|
| 167 |
return
|
|
@@ -230,7 +215,7 @@ css = """
|
|
| 230 |
|
| 231 |
# Create the Gradio Interface
|
| 232 |
with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
| 233 |
-
gr.Markdown("# **DocScope
|
| 234 |
with gr.Row():
|
| 235 |
with gr.Column():
|
| 236 |
with gr.Tabs():
|
|
@@ -259,7 +244,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 259 |
with gr.Column():
|
| 260 |
output = gr.Textbox(label="Output", interactive=False, lines=2, scale=2)
|
| 261 |
model_choice = gr.Radio(
|
| 262 |
-
choices=["Cosmos-Reason1-7B", "docscopeOCR-7B-050425-exp", "
|
| 263 |
label="Select Model",
|
| 264 |
value="Cosmos-Reason1-7B"
|
| 265 |
)
|
|
@@ -267,10 +252,8 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 267 |
gr.Markdown("**Model Info**")
|
| 268 |
gr.Markdown("⤷ [Cosmos-Reason1-7B](https://huggingface.co/nvidia/Cosmos-Reason1-7B): understand physical common sense and generate appropriate embodied decisions.")
|
| 269 |
gr.Markdown("⤷ [docscopeOCR-7B-050425-exp](https://huggingface.co/prithivMLmods/docscopeOCR-7B-050425-exp): optimized for document-level optical character recognition, long-context vision-language understanding.")
|
| 270 |
-
gr.Markdown("⤷ [MiMo-VL-7B-RL](https://huggingface.co/XiaomiMiMo/MiMo-VL-7B-RL): MiMo-7B language model, specifically optimized for complex reasoning tasks. Mixed On-policy Reinforcement Learning (MORL), a novel framework that seamlessly integrates diverse reward signals spanning perception accuracy.")
|
| 271 |
gr.Markdown("⤷ [Captioner-Relaxed-7B](https://huggingface.co/Ertugrul/Qwen2.5-VL-7B-Captioner-Relaxed): build with hand-curated dataset for text-to-image models, providing significantly more detailed descriptions or captions of given images.")
|
| 272 |
|
| 273 |
-
|
| 274 |
image_submit.click(
|
| 275 |
fn=generate_image,
|
| 276 |
inputs=[model_choice, image_query, image_upload, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
|
|
@@ -283,4 +266,4 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 283 |
)
|
| 284 |
|
| 285 |
if __name__ == "__main__":
|
| 286 |
-
demo.queue(max_size=
|
|
|
|
| 46 |
).to(device).eval()
|
| 47 |
|
| 48 |
# Load Relaxed
|
| 49 |
+
MODEL_ID_Z = "XiaomiMiMo/MiMo-VL-7B-RL"
|
| 50 |
processor_z = AutoProcessor.from_pretrained(MODEL_ID_Z, trust_remote_code=True)
|
| 51 |
model_z = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 52 |
MODEL_ID_Z,
|
|
|
|
| 54 |
torch_dtype=torch.float16
|
| 55 |
).to(device).eval()
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
def downsample_video(video_path):
|
| 58 |
"""
|
| 59 |
Downsamples the video to evenly spaced frames.
|
|
|
|
| 94 |
elif model_name == "Captioner-7B":
|
| 95 |
processor = processor_z
|
| 96 |
model = model_z
|
|
|
|
|
|
|
|
|
|
| 97 |
else:
|
| 98 |
yield "Invalid model selected."
|
| 99 |
return
|
|
|
|
| 147 |
elif model_name == "Captioner-7B":
|
| 148 |
processor = processor_z
|
| 149 |
model = model_z
|
|
|
|
|
|
|
|
|
|
| 150 |
else:
|
| 151 |
yield "Invalid model selected."
|
| 152 |
return
|
|
|
|
| 215 |
|
| 216 |
# Create the Gradio Interface
|
| 217 |
with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
| 218 |
+
gr.Markdown("# **Cosmos-x-DocScope**")
|
| 219 |
with gr.Row():
|
| 220 |
with gr.Column():
|
| 221 |
with gr.Tabs():
|
|
|
|
| 244 |
with gr.Column():
|
| 245 |
output = gr.Textbox(label="Output", interactive=False, lines=2, scale=2)
|
| 246 |
model_choice = gr.Radio(
|
| 247 |
+
choices=["Cosmos-Reason1-7B", "docscopeOCR-7B-050425-exp", "Captioner-7B"],
|
| 248 |
label="Select Model",
|
| 249 |
value="Cosmos-Reason1-7B"
|
| 250 |
)
|
|
|
|
| 252 |
gr.Markdown("**Model Info**")
|
| 253 |
gr.Markdown("⤷ [Cosmos-Reason1-7B](https://huggingface.co/nvidia/Cosmos-Reason1-7B): understand physical common sense and generate appropriate embodied decisions.")
|
| 254 |
gr.Markdown("⤷ [docscopeOCR-7B-050425-exp](https://huggingface.co/prithivMLmods/docscopeOCR-7B-050425-exp): optimized for document-level optical character recognition, long-context vision-language understanding.")
|
|
|
|
| 255 |
gr.Markdown("⤷ [Captioner-Relaxed-7B](https://huggingface.co/Ertugrul/Qwen2.5-VL-7B-Captioner-Relaxed): build with hand-curated dataset for text-to-image models, providing significantly more detailed descriptions or captions of given images.")
|
| 256 |
|
|
|
|
| 257 |
image_submit.click(
|
| 258 |
fn=generate_image,
|
| 259 |
inputs=[model_choice, image_query, image_upload, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
|
|
|
|
| 266 |
)
|
| 267 |
|
| 268 |
if __name__ == "__main__":
|
| 269 |
+
demo.queue(max_size=30).launch(share=True, mcp_server=True, ssr_mode=False, show_error=True)
|