prithivMLmods commited on
Commit
1647910
·
verified ·
1 Parent(s): db025f4

update app

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -138,6 +138,24 @@ model_y = Qwen3VLForConditionalGeneration.from_pretrained(
138
  torch_dtype=torch.float16
139
  ).to(device).eval()
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  # Load Qwen3-VL-4B-Thinking
142
  MODEL_ID_T = "Qwen/Qwen3-VL-4B-Thinking"
143
  processor_t = AutoProcessor.from_pretrained(MODEL_ID_T, trust_remote_code=True)
@@ -189,6 +207,10 @@ def generate_image(model_name: str, text: str, image: Image.Image,
189
  processor, model = processor_y, model_y
190
  elif model_name == "Qwen3-VL-4B-Thinking":
191
  processor, model = processor_t, model_t
 
 
 
 
192
  else:
193
  yield "Invalid model selected.", "Invalid model selected."
194
  return
@@ -231,6 +253,10 @@ def generate_video(model_name: str, text: str, video_path: str,
231
  processor, model = processor_y, model_y
232
  elif model_name == "Qwen3-VL-4B-Thinking":
233
  processor, model = processor_t, model_t
 
 
 
 
234
  else:
235
  yield "Invalid model selected.", "Invalid model selected."
236
  return
@@ -275,8 +301,8 @@ image_examples = [
275
  ["Explain the content (ocr).", "images/O.jpg"],
276
  ["What is the core meaning of the poem?", "images/S.jpg"],
277
  ["Provide a detailed caption for the image.", "images/A.jpg"],
278
- ["Explain the pie-chart in detail.", "images/2.jpg"],
279
- ["Jsonify Data.", "images/1.jpg"],
280
  ]
281
 
282
  video_examples = [
@@ -325,7 +351,7 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
325
  markdown_output = gr.Markdown()
326
 
327
  model_choice = gr.Radio(
328
- choices=["Qwen3-VL-4B-Instruct", "Qwen3-VL-8B-Instruct", "Qwen3-VL-4B-Thinking", "Qwen2.5-VL-3B-Instruct", "Qwen2.5-VL-7B-Instruct"],
329
  label="Select Model",
330
  value="Qwen3-VL-4B-Instruct"
331
  )
 
138
  torch_dtype=torch.float16
139
  ).to(device).eval()
140
 
141
+ # Load Qwen3-VL-2B-Instruct
142
+ MODEL_ID_L = "Qwen/Qwen3-VL-2B-Instruct"
143
+ processor_l = AutoProcessor.from_pretrained(MODEL_ID_L, trust_remote_code=True)
144
+ model_l = Qwen3VLForConditionalGeneration.from_pretrained(
145
+ MODEL_ID_L,
146
+ trust_remote_code=True,
147
+ torch_dtype=torch.float16
148
+ ).to(device).eval()
149
+
150
+ # Load Qwen3-VL-2B-Thinking
151
+ MODEL_ID_J = "Qwen/Qwen3-VL-2B-Thinking"
152
+ processor_j = AutoProcessor.from_pretrained(MODEL_ID_J, trust_remote_code=True)
153
+ model_j = Qwen3VLForConditionalGeneration.from_pretrained(
154
+ MODEL_ID_J,
155
+ trust_remote_code=True,
156
+ torch_dtype=torch.float16
157
+ ).to(device).eval()
158
+
159
  # Load Qwen3-VL-4B-Thinking
160
  MODEL_ID_T = "Qwen/Qwen3-VL-4B-Thinking"
161
  processor_t = AutoProcessor.from_pretrained(MODEL_ID_T, trust_remote_code=True)
 
207
  processor, model = processor_y, model_y
208
  elif model_name == "Qwen3-VL-4B-Thinking":
209
  processor, model = processor_t, model_t
210
+ elif model_name == "Qwen3-VL-2B-Instruct":
211
+ processor, model = processor_l, model_l
212
+ elif model_name == "Qwen3-VL-2B-Thinking":
213
+ processor, model = processor_j, model_j
214
  else:
215
  yield "Invalid model selected.", "Invalid model selected."
216
  return
 
253
  processor, model = processor_y, model_y
254
  elif model_name == "Qwen3-VL-4B-Thinking":
255
  processor, model = processor_t, model_t
256
+ elif model_name == "Qwen3-VL-2B-Instruct":
257
+ processor, model = processor_l, model_l
258
+ elif model_name == "Qwen3-VL-2B-Thinking":
259
+ processor, model = processor_j, model_j
260
  else:
261
  yield "Invalid model selected.", "Invalid model selected."
262
  return
 
301
  ["Explain the content (ocr).", "images/O.jpg"],
302
  ["What is the core meaning of the poem?", "images/S.jpg"],
303
  ["Provide a detailed caption for the image.", "images/A.jpg"],
304
+ #["Explain the pie-chart in detail.", "images/2.jpg"],
305
+ #["Jsonify Data.", "images/1.jpg"],
306
  ]
307
 
308
  video_examples = [
 
351
  markdown_output = gr.Markdown()
352
 
353
  model_choice = gr.Radio(
354
+ choices=["Qwen3-VL-4B-Instruct", "Qwen3-VL-8B-Instruct", "Qwen3-VL-2B-Instruct", "Qwen3-VL-2B-Thinking", "Qwen3-VL-4B-Thinking", "Qwen2.5-VL-3B-Instruct", "Qwen2.5-VL-7B-Instruct"],
355
  label="Select Model",
356
  value="Qwen3-VL-4B-Instruct"
357
  )