Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -54,7 +54,11 @@ async def cartoonize_image(file: UploadFile = File(...)):
|
|
| 54 |
image = Image.open(io.BytesIO(contents))
|
| 55 |
image = np.array(image)
|
| 56 |
cartoonized_image = inference(image)
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
| 60 |
|
|
|
|
| 54 |
image = Image.open(io.BytesIO(contents))
|
| 55 |
image = np.array(image)
|
| 56 |
cartoonized_image = inference(image)
|
| 57 |
+
|
| 58 |
+
# Convert BGR to RGB format
|
| 59 |
+
cartoonized_image_rgb = cv2.cvtColor(cartoonized_image, cv2.COLOR_BGR2RGB)
|
| 60 |
+
|
| 61 |
+
return StreamingResponse(io.BytesIO(cv2.imencode('.jpg', cartoonized_image_rgb)[1]), media_type="image/jpeg")
|
| 62 |
|
| 63 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
| 64 |
|