crisrm128 commited on
Commit
a552163
·
1 Parent(s): d63daaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -12
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
- # Encode the byte stream as a base64 string
49
- image_base64 = base64.b64encode(image_byte_array.getvalue()).decode("utf-8")
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)}")