Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -177,9 +177,16 @@ async def analyze_image(file: UploadFile = File(...)):
|
|
177 |
|
178 |
# Generate content using the AI model
|
179 |
response = model.generate_content([prompt, blob])
|
|
|
|
|
|
|
180 |
|
|
|
|
|
|
|
|
|
181 |
# Return the AI-generated response
|
182 |
-
return JSONResponse(content=
|
183 |
|
184 |
|
185 |
|
|
|
177 |
|
178 |
# Generate content using the AI model
|
179 |
response = model.generate_content([prompt, blob])
|
180 |
+
|
181 |
+
# Remove extra characters and escape sequences
|
182 |
+
cleaned_response = re.sub(r'\\n|json', '', response.text).strip()
|
183 |
|
184 |
+
# Parse the cleaned string as JSON
|
185 |
+
data = json.loads(cleaned_response)
|
186 |
+
fd = json.dumps(data, indent=4)
|
187 |
+
|
188 |
# Return the AI-generated response
|
189 |
+
return JSONResponse(content=fd ,media_type="application/json")
|
190 |
|
191 |
|
192 |
|