prithivMLmods commited on
Commit
c7a140a
·
verified ·
1 Parent(s): ceece79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -173,18 +173,14 @@ def annotate_image(image: Image.Image, result: dict):
173
 
174
  @GPU
175
  def process_qwen(image: Image.Image, category: str, prompt: str):
176
- """Processes the input based on the selected category using the Qwen model."""
177
  if category == "Query":
178
  return run_qwen_inference(image, prompt), {}
179
-
180
  elif category == "Caption":
181
  full_prompt = f"Provide a {prompt} length caption for the image."
182
  return run_qwen_inference(image, full_prompt), {}
183
-
184
  elif category == "Point":
185
  full_prompt = (
186
- f"Provide 2d point coordinates for {prompt}. Report in JSON format like "
187
- `[{"point_2d": [x, y]}]` " where coordinates are from 0 to 1000."
188
  )
189
  output_text = run_qwen_inference(image, full_prompt)
190
  parsed_json = safe_parse_json(output_text)
@@ -195,11 +191,9 @@ def process_qwen(image: Image.Image, category: str, prompt: str):
195
  x, y = item["point_2d"]
196
  points_result["points"].append({"x": x / 1000.0, "y": y / 1000.0})
197
  return json.dumps(points_result, indent=2), points_result
198
-
199
  elif category == "Detect":
200
  full_prompt = (
201
- f"Provide bounding box coordinates for {prompt}. Report in JSON format like "
202
- `[{"bbox_2d": [xmin, ymin, xmax, ymax]}]` " where coordinates are from 0 to 1000."
203
  )
204
  output_text = run_qwen_inference(image, full_prompt)
205
  parsed_json = safe_parse_json(output_text)
@@ -217,7 +211,6 @@ def process_qwen(image: Image.Image, category: str, prompt: str):
217
  }
218
  )
219
  return json.dumps(objects_result, indent=2), objects_result
220
-
221
  return "Invalid category", {}
222
 
223
 
 
173
 
174
  @GPU
175
  def process_qwen(image: Image.Image, category: str, prompt: str):
 
176
  if category == "Query":
177
  return run_qwen_inference(image, prompt), {}
 
178
  elif category == "Caption":
179
  full_prompt = f"Provide a {prompt} length caption for the image."
180
  return run_qwen_inference(image, full_prompt), {}
 
181
  elif category == "Point":
182
  full_prompt = (
183
+ f"Provide 2d point coordinates for {prompt}. Report in JSON format."
 
184
  )
185
  output_text = run_qwen_inference(image, full_prompt)
186
  parsed_json = safe_parse_json(output_text)
 
191
  x, y = item["point_2d"]
192
  points_result["points"].append({"x": x / 1000.0, "y": y / 1000.0})
193
  return json.dumps(points_result, indent=2), points_result
 
194
  elif category == "Detect":
195
  full_prompt = (
196
+ f"Provide bounding box coordinates for {prompt}. Report in JSON format."
 
197
  )
198
  output_text = run_qwen_inference(image, full_prompt)
199
  parsed_json = safe_parse_json(output_text)
 
211
  }
212
  )
213
  return json.dumps(objects_result, indent=2), objects_result
 
214
  return "Invalid category", {}
215
 
216