Spaces:
Sleeping
Sleeping
Update utils/basic_functions.py
Browse files- 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 |
-
|
| 134 |
-
|
|
|
|
|
|
|
| 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
|
|
|
|
| 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"]
|