bcvilnrotter commited on
Commit
cba8c8b
·
verified ·
1 Parent(s): ce475e7

Update utils/basic_functions.py

Browse files
Files changed (1) hide show
  1. utils/basic_functions.py +5 -3
utils/basic_functions.py CHANGED
@@ -130,8 +130,10 @@ def huggingface_detect_id_box(model_name,url):
130
  response_string = processor.decode(output[0][2:],skip_special_tokens=True)
131
  print(f"response_string: {response_string}")
132
 
133
- bbox = re.search(r"ASSISTANT: \[(.*?)\]",response_string)
134
- bbox = [image.size[0],image.size[1],image.size[0],image.size[1]]*ast.literal_eval([bbox])
 
 
135
  print(f"bbox: {bbox}")
136
 
137
 
@@ -145,4 +147,4 @@ def huggingface_detect_id_box(model_name,url):
145
  return [image,bbox]
146
  except Exception as e:
147
  print(f"Error loading model or processing image: {str(e)}")
148
- return None
 
130
  response_string = processor.decode(output[0][2:],skip_special_tokens=True)
131
  print(f"response_string: {response_string}")
132
 
133
+ match = re.search(r"ASSISTANT: \[(.*?)\]",response_string)
134
+ if not match:
135
+ return [image,"no match found"]
136
+ bbox = [image.size[0],image.size[1],image.size[0],image.size[1]]*ast.literal_eval([match.group(1)])
137
  print(f"bbox: {bbox}")
138
 
139
 
 
147
  return [image,bbox]
148
  except Exception as e:
149
  print(f"Error loading model or processing image: {str(e)}")
150
+ return [image,"an error occurred processing request"]