Spaces:
Running
on
Zero
Running
on
Zero
Update models.py
Browse files
models.py
CHANGED
|
@@ -133,6 +133,18 @@ class BagelAPIAnalyzer(BaseImageAnalyzer):
|
|
| 133 |
return "BAGEL API not available", {"error": "API initialization failed"}
|
| 134 |
|
| 135 |
temp_path = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
try:
|
| 137 |
# Default prompt for detailed image analysis
|
| 138 |
if prompt is None:
|
|
@@ -183,16 +195,10 @@ Format your response clearly with these two sections."""
|
|
| 183 |
description = "Detailed image analysis completed successfully"
|
| 184 |
metadata["has_camera_suggestion"] = False
|
| 185 |
|
| 186 |
-
#
|
| 187 |
-
metadata
|
| 188 |
-
"model": "BAGEL-7B-API",
|
| 189 |
-
"device": "api",
|
| 190 |
-
"confidence": 0.9,
|
| 191 |
-
"api_endpoint": self.api_endpoint,
|
| 192 |
-
"space_url": self.space_url,
|
| 193 |
-
"prompt_used": prompt,
|
| 194 |
"response_length": len(description)
|
| 195 |
-
}
|
| 196 |
|
| 197 |
logger.info(f"BAGEL API analysis complete: {len(description)} characters")
|
| 198 |
return description, metadata
|
|
|
|
| 133 |
return "BAGEL API not available", {"error": "API initialization failed"}
|
| 134 |
|
| 135 |
temp_path = None
|
| 136 |
+
|
| 137 |
+
# Initialize metadata early
|
| 138 |
+
metadata = {
|
| 139 |
+
"model": "BAGEL-7B-API",
|
| 140 |
+
"device": "api",
|
| 141 |
+
"confidence": 0.9,
|
| 142 |
+
"api_endpoint": self.api_endpoint,
|
| 143 |
+
"space_url": self.space_url,
|
| 144 |
+
"prompt_used": prompt,
|
| 145 |
+
"has_camera_suggestion": False
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
try:
|
| 149 |
# Default prompt for detailed image analysis
|
| 150 |
if prompt is None:
|
|
|
|
| 195 |
description = "Detailed image analysis completed successfully"
|
| 196 |
metadata["has_camera_suggestion"] = False
|
| 197 |
|
| 198 |
+
# Update final metadata
|
| 199 |
+
metadata.update({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
"response_length": len(description)
|
| 201 |
+
})
|
| 202 |
|
| 203 |
logger.info(f"BAGEL API analysis complete: {len(description)} characters")
|
| 204 |
return description, metadata
|