Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -180,9 +180,12 @@ async def analyze_image(file: UploadFile = File(...)):
|
|
180 |
# Generate content using the AI model
|
181 |
response = model.generate_content([prompt, blob])
|
182 |
|
183 |
-
#
|
184 |
-
|
185 |
|
|
|
|
|
|
|
186 |
# Parse the cleaned string as JSON
|
187 |
data = json.loads(cleaned_response)
|
188 |
fd = json.dumps(data, indent=4)
|
|
|
180 |
# Generate content using the AI model
|
181 |
response = model.generate_content([prompt, blob])
|
182 |
|
183 |
+
# Extract JSON string from Markdown-formatted JSON string
|
184 |
+
json_string = re.search(r'```json(.*?)```', response.text, re.DOTALL).group(1)
|
185 |
|
186 |
+
# Clean JSON string
|
187 |
+
cleaned_response = json_string.strip()
|
188 |
+
|
189 |
# Parse the cleaned string as JSON
|
190 |
data = json.loads(cleaned_response)
|
191 |
fd = json.dumps(data, indent=4)
|