ivelin commited on
Commit
1e72178
1 Parent(s): 63af266

fix: bbox bugs

Browse files

Signed-off-by: ivelin <ivelin.eth@gmail.com>

Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -54,14 +54,14 @@ def process_refexp(image: Image, prompt: str):
54
  sequence = re.sub(r"<.*?>", "", sequence, count=1).strip()
55
  print(
56
  fr"predicted decoder sequence before token2json: {html.escape(sequence)}")
57
- bbox = processor.token2json(sequence)
58
 
59
  # safeguard in case predicted sequence does not include a target_bounding_box token
60
- bbox = target_bbox.get('target_bounding_box')
61
  if bbox is None:
62
  print(
63
  f"token2bbox seq has no predicted target_bounding_box, seq:{seq}")
64
- bbox = bbox = {"xmin": 0, "ymin": 0, "xmax": 0, "ymax": 0}
65
  return bbox
66
 
67
  print(f"predicted bounding box with text coordinates: {bbox}")
 
54
  sequence = re.sub(r"<.*?>", "", sequence, count=1).strip()
55
  print(
56
  fr"predicted decoder sequence before token2json: {html.escape(sequence)}")
57
+ seqjson = processor.token2json(sequence)
58
 
59
  # safeguard in case predicted sequence does not include a target_bounding_box token
60
+ bbox = seqjson.get('target_bounding_box')
61
  if bbox is None:
62
  print(
63
  f"token2bbox seq has no predicted target_bounding_box, seq:{seq}")
64
+ bbox = {"xmin": 0, "ymin": 0, "xmax": 0, "ymax": 0}
65
  return bbox
66
 
67
  print(f"predicted bounding box with text coordinates: {bbox}")