Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,6 +54,15 @@ model_z = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
| 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,6 +103,9 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
| 94 |
elif model_name == "Captioner-7B":
|
| 95 |
processor = processor_z
|
| 96 |
model = model_z
|
|
|
|
|
|
|
|
|
|
| 97 |
else:
|
| 98 |
yield "Invalid model selected."
|
| 99 |
return
|
|
@@ -125,7 +137,6 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
| 125 |
buffer = ""
|
| 126 |
for new_text in streamer:
|
| 127 |
buffer += new_text
|
| 128 |
-
buffer = buffer.replace("<|im_end|>", "")
|
| 129 |
time.sleep(0.01)
|
| 130 |
yield buffer
|
| 131 |
|
|
@@ -148,6 +159,9 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
| 148 |
elif model_name == "Captioner-7B":
|
| 149 |
processor = processor_z
|
| 150 |
model = model_z
|
|
|
|
|
|
|
|
|
|
| 151 |
else:
|
| 152 |
yield "Invalid model selected."
|
| 153 |
return
|
|
@@ -190,7 +204,6 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
| 190 |
buffer = ""
|
| 191 |
for new_text in streamer:
|
| 192 |
buffer += new_text
|
| 193 |
-
buffer = buffer.replace("<|im_end|>", "")
|
| 194 |
time.sleep(0.01)
|
| 195 |
yield buffer
|
| 196 |
|
|
@@ -246,7 +259,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 246 |
with gr.Column():
|
| 247 |
output = gr.Textbox(label="Output", interactive=False, lines=2, scale=2)
|
| 248 |
model_choice = gr.Radio(
|
| 249 |
-
choices=["Cosmos-Reason1-7B", "docscopeOCR-7B-050425-exp", "Captioner-7B"],
|
| 250 |
label="Select Model",
|
| 251 |
value="Cosmos-Reason1-7B"
|
| 252 |
)
|
|
@@ -254,8 +267,10 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 254 |
gr.Markdown("**Model Info**")
|
| 255 |
gr.Markdown("⤷ [Cosmos-Reason1-7B](https://huggingface.co/nvidia/Cosmos-Reason1-7B): understand physical common sense and generate appropriate embodied decisions.")
|
| 256 |
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.")
|
|
|
|
| 257 |
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.")
|
| 258 |
|
|
|
|
| 259 |
image_submit.click(
|
| 260 |
fn=generate_image,
|
| 261 |
inputs=[model_choice, image_query, image_upload, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
|
|
@@ -268,4 +283,4 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 268 |
)
|
| 269 |
|
| 270 |
if __name__ == "__main__":
|
| 271 |
-
demo.queue(max_size=
|
|
|
|
| 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 |
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
|
|
|
|
| 137 |
buffer = ""
|
| 138 |
for new_text in streamer:
|
| 139 |
buffer += new_text
|
|
|
|
| 140 |
time.sleep(0.01)
|
| 141 |
yield buffer
|
| 142 |
|
|
|
|
| 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
|
|
|
|
| 204 |
buffer = ""
|
| 205 |
for new_text in streamer:
|
| 206 |
buffer += new_text
|
|
|
|
| 207 |
time.sleep(0.01)
|
| 208 |
yield buffer
|
| 209 |
|
|
|
|
| 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", "Mimo-7B-RL", "Captioner-7B"],
|
| 263 |
label="Select Model",
|
| 264 |
value="Cosmos-Reason1-7B"
|
| 265 |
)
|
|
|
|
| 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 |
)
|
| 284 |
|
| 285 |
if __name__ == "__main__":
|
| 286 |
+
demo.queue(max_size=40).launch(share=True, mcp_server=True, ssr_mode=False, show_error=True)
|