Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,18 +45,8 @@ def detect_objects(url: str):
|
|
| 45 |
image_byte_array = io.BytesIO()
|
| 46 |
image.save(image_byte_array, format="PNG")
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
# Create a custom HTML response
|
| 52 |
-
html_content = f"""
|
| 53 |
-
<html>
|
| 54 |
-
<body>
|
| 55 |
-
<img src="data:image/png;base64,{image_base64}" alt="Detected Objects">
|
| 56 |
-
</body>
|
| 57 |
-
</html>
|
| 58 |
-
"""
|
| 59 |
-
return HTMLResponse(content=html_content)
|
| 60 |
|
| 61 |
except Exception as e:
|
| 62 |
raise HTTPException(status_code=500, detail=f"Error processing image: {str(e)}")
|
|
|
|
| 45 |
image_byte_array = io.BytesIO()
|
| 46 |
image.save(image_byte_array, format="PNG")
|
| 47 |
|
| 48 |
+
# Return the image as a Response with content type "image/png"
|
| 49 |
+
return Response(content=image_byte_array.getvalue(), media_type="image/png")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
except Exception as e:
|
| 52 |
raise HTTPException(status_code=500, detail=f"Error processing image: {str(e)}")
|