prithivMLmods commited on
Commit
e695261
·
verified ·
1 Parent(s): 06a2da0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -56,6 +56,15 @@ model_q = Qwen2_5_VLForConditionalGeneration.from_pretrained(
56
  torch_dtype=torch.float16
57
  ).to(device).eval()
58
 
 
 
 
 
 
 
 
 
 
59
  def downsample_video(video_path):
60
  """
61
  Downsamples the video to evenly spaced frames.
@@ -97,6 +106,9 @@ def generate_image(model_name: str, text: str, image: Image.Image,
97
  elif model_name == "Qwen2.5-VL-7B-Abliterated-Caption-it":
98
  processor = processor_q
99
  model = model_q
 
 
 
100
  else:
101
  yield "Invalid model selected.", "Invalid model selected."
102
  return
@@ -151,6 +163,9 @@ def generate_video(model_name: str, text: str, video_path: str,
151
  elif model_name == "Qwen2.5-VL-7B-Abliterated-Caption-it":
152
  processor = processor_q
153
  model = model_q
 
 
 
154
  else:
155
  yield "Invalid model selected.", "Invalid model selected."
156
  return
@@ -262,7 +277,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
262
  markdown_output = gr.Markdown()
263
 
264
  model_choice = gr.Radio(
265
- choices=["Qwen2.5-VL-7B-Instruct", "Qwen2.5-VL-3B-Instruct", "Qwen2.5-VL-7B-Abliterated-Caption-it"],
266
  label="Select Model",
267
  value="Qwen2.5-VL-7B-Instruct"
268
  )
@@ -270,6 +285,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
270
  gr.Markdown("> [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct): The Qwen2.5-VL-7B-Instruct model is a multimodal AI model developed by Alibaba Cloud that excels at understanding both text and images. It's a Vision-Language Model (VLM) designed to handle various visual understanding tasks, including image understanding, video analysis, and even multilingual support.")
271
  gr.Markdown("> [Qwen2.5-VL-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct): Qwen2.5-VL-3B-Instruct is an instruction-tuned vision-language model from Alibaba Cloud, built upon the Qwen2-VL series. It excels at understanding and generating text related to both visual and textual inputs, making it capable of tasks like image captioning, visual question answering, and object localization. The model also supports long video understanding and structured data extraction")
272
  gr.Markdown("> [Qwen2.5-VL-7B-Abliterated-Caption-it](prithivMLmods/Qwen2.5-VL-7B-Abliterated-Caption-it): Qwen2.5-VL-7B-Abliterated-Caption-it is a fine-tuned version of Qwen2.5-VL-7B-Instruct, optimized for Abliterated Captioning / Uncensored Captioning. This model excels at generating detailed, context-rich, and high-fidelity captions across diverse image categories and variational aspect ratios, offering robust visual understanding without filtering or censorship.")
 
273
  gr.Markdown(">⚠️note: all the models in space are not guaranteed to perform well in video inference use cases.")
274
 
275
  image_submit.click(
 
56
  torch_dtype=torch.float16
57
  ).to(device).eval()
58
 
59
+ # Load YannQi/X-VL-4B
60
+ MODEL_ID_I = "YannQi/X-VL-4B"
61
+ processor_i= AutoProcessor.from_pretrained(MODEL_ID_I, trust_remote_code=True)
62
+ model_i = AutoModel.from_pretrained(
63
+ MODEL_ID_I,
64
+ trust_remote_code=True,
65
+ torch_dtype=torch.float16
66
+ ).to(device).eval()
67
+
68
  def downsample_video(video_path):
69
  """
70
  Downsamples the video to evenly spaced frames.
 
106
  elif model_name == "Qwen2.5-VL-7B-Abliterated-Caption-it":
107
  processor = processor_q
108
  model = model_q
109
+ elif model_name == "X-VL-4B":
110
+ processor = processor_i
111
+ model = model_i
112
  else:
113
  yield "Invalid model selected.", "Invalid model selected."
114
  return
 
163
  elif model_name == "Qwen2.5-VL-7B-Abliterated-Caption-it":
164
  processor = processor_q
165
  model = model_q
166
+ elif model_name == "X-VL-4B":
167
+ processor = processor_i
168
+ model = model_i
169
  else:
170
  yield "Invalid model selected.", "Invalid model selected."
171
  return
 
277
  markdown_output = gr.Markdown()
278
 
279
  model_choice = gr.Radio(
280
+ choices=["Qwen2.5-VL-7B-Instruct", "Qwen2.5-VL-3B-Instruct", "X-VL-4B", "Qwen2.5-VL-7B-Abliterated-Caption-it"],
281
  label="Select Model",
282
  value="Qwen2.5-VL-7B-Instruct"
283
  )
 
285
  gr.Markdown("> [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct): The Qwen2.5-VL-7B-Instruct model is a multimodal AI model developed by Alibaba Cloud that excels at understanding both text and images. It's a Vision-Language Model (VLM) designed to handle various visual understanding tasks, including image understanding, video analysis, and even multilingual support.")
286
  gr.Markdown("> [Qwen2.5-VL-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct): Qwen2.5-VL-3B-Instruct is an instruction-tuned vision-language model from Alibaba Cloud, built upon the Qwen2-VL series. It excels at understanding and generating text related to both visual and textual inputs, making it capable of tasks like image captioning, visual question answering, and object localization. The model also supports long video understanding and structured data extraction")
287
  gr.Markdown("> [Qwen2.5-VL-7B-Abliterated-Caption-it](prithivMLmods/Qwen2.5-VL-7B-Abliterated-Caption-it): Qwen2.5-VL-7B-Abliterated-Caption-it is a fine-tuned version of Qwen2.5-VL-7B-Instruct, optimized for Abliterated Captioning / Uncensored Captioning. This model excels at generating detailed, context-rich, and high-fidelity captions across diverse image categories and variational aspect ratios, offering robust visual understanding without filtering or censorship.")
288
+ gr.Markdown("> [X-VL-4B](huggingface.co/YannQi/X-VL-4B): X-VL-4B, a multimodal large language model designed to achieve adaptive multimodal reasoning—dynamically choosing between step-by-step thinking and direct response generation based on task complexity. This capability enables X-VL-4B to deliver high-quality responses while significantly improving inference efficiency and reducing computational costs")
289
  gr.Markdown(">⚠️note: all the models in space are not guaranteed to perform well in video inference use cases.")
290
 
291
  image_submit.click(