Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
from fastapi import FastAPI, Request,
|
|
|
2 |
from contextlib import asynccontextmanager
|
3 |
from starlette.middleware.cors import CORSMiddleware
|
4 |
|
@@ -58,8 +59,8 @@ async def text_to_image(
|
|
58 |
|
59 |
bytes = BytesIO()
|
60 |
image.save(bytes, "PNG")
|
61 |
-
|
62 |
-
return
|
63 |
|
64 |
|
65 |
@app.post("/image-to-image/")
|
@@ -84,8 +85,8 @@ async def image_to_image(
|
|
84 |
|
85 |
bytes = BytesIO()
|
86 |
image.save(bytes, "PNG")
|
87 |
-
|
88 |
-
return
|
89 |
|
90 |
|
91 |
@app.post("/inpainting/")
|
@@ -115,5 +116,5 @@ async def inpainting(
|
|
115 |
|
116 |
bytes = BytesIO()
|
117 |
image.save(bytes, "PNG")
|
118 |
-
|
119 |
-
return
|
|
|
1 |
+
from fastapi import FastAPI, Request, Form, File, UploadFile
|
2 |
+
from fastapi.responses import StreamingResponse
|
3 |
from contextlib import asynccontextmanager
|
4 |
from starlette.middleware.cors import CORSMiddleware
|
5 |
|
|
|
59 |
|
60 |
bytes = BytesIO()
|
61 |
image.save(bytes, "PNG")
|
62 |
+
bytes.seek(0)
|
63 |
+
return StreamingResponse(bytes, media_type="image/png")
|
64 |
|
65 |
|
66 |
@app.post("/image-to-image/")
|
|
|
85 |
|
86 |
bytes = BytesIO()
|
87 |
image.save(bytes, "PNG")
|
88 |
+
bytes.seek(0)
|
89 |
+
return StreamingResponse(bytes, media_type="image/png")
|
90 |
|
91 |
|
92 |
@app.post("/inpainting/")
|
|
|
116 |
|
117 |
bytes = BytesIO()
|
118 |
image.save(bytes, "PNG")
|
119 |
+
bytes.seek(0)
|
120 |
+
return StreamingResponse(bytes, media_type="image/png")
|