artificialguybr commited on
Commit
f23c17c
·
1 Parent(s): 32f13d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -11,7 +11,8 @@ model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-VL-Chat-Int4", device_ma
11
 
12
  def generate_predictions(image_input, text_input, with_grounding):
13
  user_image_path = "/tmp/user_input_test_image.jpg"
14
- Image.fromarray((255 - (image_input * 255).astype('uint8'))).save(user_image_path)
 
15
 
16
  if with_grounding == "Yes":
17
  text_input += " with grounding"
@@ -31,6 +32,10 @@ def generate_predictions(image_input, text_input, with_grounding):
31
 
32
  image_with_boxes = tokenizer.draw_bbox_on_latest_picture(full_response)
33
 
 
 
 
 
34
  if image_with_boxes:
35
  temp_path = "/tmp/image_with_boxes.jpg"
36
  image_with_boxes.save(temp_path)
 
11
 
12
  def generate_predictions(image_input, text_input, with_grounding):
13
  user_image_path = "/tmp/user_input_test_image.jpg"
14
+ original_image = Image.fromarray((255 - (image_input * 255).astype('uint8')))
15
+ original_image.save(user_image_path)
16
 
17
  if with_grounding == "Yes":
18
  text_input += " with grounding"
 
32
 
33
  image_with_boxes = tokenizer.draw_bbox_on_latest_picture(full_response)
34
 
35
+ # Check if the response contains bounding box coordinates
36
+ if not re.search(r'\(\d+,\d+\),\(\d+,\d+\)', frontend_response):
37
+ image_with_boxes = original_image
38
+
39
  if image_with_boxes:
40
  temp_path = "/tmp/image_with_boxes.jpg"
41
  image_with_boxes.save(temp_path)