Gopal2002 commited on
Commit
d9d57fd
1 Parent(s): a7b2010

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -35,7 +35,7 @@ def array_to_image_path(image_array):
35
  return full_path
36
 
37
  models = {
38
- "Qwen/Qwen2-VL-7B-Instruct": Qwen2VLForConditionalGeneration.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", trust_remote_code=True, torch_dtype=torch.float16,device_map='auto')
39
 
40
  }
41
 
@@ -52,7 +52,7 @@ user_prompt = '<|user|>\n'
52
  assistant_prompt = '<|assistant|>\n'
53
  prompt_suffix = "<|end|>\n"
54
 
55
- # @spaces.GPU
56
  def run_example(image, text_input=None, model_id="Qwen/Qwen2-VL-7B-Instruct"):
57
  image_path = array_to_image_path(image)
58
 
@@ -87,7 +87,8 @@ def run_example(image, text_input=None, model_id="Qwen/Qwen2-VL-7B-Instruct"):
87
  padding=True,
88
  return_tensors="pt",
89
  )
90
- # inputs = inputs.to("cuda")
 
91
  # Inference: Generation of the output
92
  generated_ids = model.generate(**inputs, max_new_tokens=1024)
93
  generated_ids_trimmed = [
 
35
  return full_path
36
 
37
  models = {
38
+ "Qwen/Qwen2-VL-7B-Instruct": Qwen2VLForConditionalGeneration.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", trust_remote_code=True, torch_dtype="auto").cuda().eval()
39
 
40
  }
41
 
 
52
  assistant_prompt = '<|assistant|>\n'
53
  prompt_suffix = "<|end|>\n"
54
 
55
+ @spaces.GPU
56
  def run_example(image, text_input=None, model_id="Qwen/Qwen2-VL-7B-Instruct"):
57
  image_path = array_to_image_path(image)
58
 
 
87
  padding=True,
88
  return_tensors="pt",
89
  )
90
+ inputs = inputs.to("cuda")
91
+
92
  # Inference: Generation of the output
93
  generated_ids = model.generate(**inputs, max_new_tokens=1024)
94
  generated_ids_trimmed = [