ahmedmbutt commited on
Commit
a7bb604
·
verified ·
1 Parent(s): 760e14f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -7
main.py CHANGED
@@ -1,4 +1,5 @@
1
- from fastapi import FastAPI, Request, Response, Form, File, UploadFile
 
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
- # bytes.seek(0)
62
- return Response(content=bytes, media_type="image/png")
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
- # bytes.seek(0)
88
- return Response(content=bytes, media_type="image/png")
89
 
90
 
91
  @app.post("/inpainting/")
@@ -115,5 +116,5 @@ async def inpainting(
115
 
116
  bytes = BytesIO()
117
  image.save(bytes, "PNG")
118
- # bytes.seek(0)
119
- return Response(content=bytes, media_type="image/png")
 
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")