Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -49,7 +49,9 @@ async def root():
|
|
49 |
|
50 |
@app.post("/text-to-image/")
|
51 |
async def text_to_image(
|
52 |
-
request: Request,
|
|
|
|
|
53 |
):
|
54 |
image = request.state.text2img(
|
55 |
prompt=prompt, num_inference_steps=num_inference_steps, guidance_scale=0.0
|
@@ -65,12 +67,12 @@ async def text_to_image(
|
|
65 |
async def image_to_image(
|
66 |
request: Request,
|
67 |
prompt: str = Form(...),
|
68 |
-
|
69 |
num_inference_steps: int = Form(2),
|
70 |
-
strength: float = Form(0
|
71 |
):
|
72 |
-
|
73 |
-
init_image = Image.open(BytesIO(
|
74 |
init_image = init_image.convert("RGB").resize((512, 512))
|
75 |
|
76 |
image = request.state.img2img(
|
@@ -91,16 +93,16 @@ async def image_to_image(
|
|
91 |
async def inpainting(
|
92 |
request: Request,
|
93 |
prompt: str = Form(...),
|
94 |
-
|
95 |
-
|
96 |
-
num_inference_steps: int = Form(
|
97 |
-
strength: float = Form(0
|
98 |
):
|
99 |
-
|
100 |
-
init_image = Image.open(BytesIO(
|
101 |
init_image = init_image.convert("RGB").resize((512, 512))
|
102 |
-
|
103 |
-
mask_image = Image.open(BytesIO(
|
104 |
mask_image = mask_image.convert("RGB").resize((512, 512))
|
105 |
|
106 |
image = request.state.inpaint(
|
|
|
49 |
|
50 |
@app.post("/text-to-image/")
|
51 |
async def text_to_image(
|
52 |
+
request: Request,
|
53 |
+
prompt: str = Form(...),
|
54 |
+
num_inference_steps: int = Form(1),
|
55 |
):
|
56 |
image = request.state.text2img(
|
57 |
prompt=prompt, num_inference_steps=num_inference_steps, guidance_scale=0.0
|
|
|
67 |
async def image_to_image(
|
68 |
request: Request,
|
69 |
prompt: str = Form(...),
|
70 |
+
init_bytes: bytes = Form(...),
|
71 |
num_inference_steps: int = Form(2),
|
72 |
+
strength: float = Form(1.0),
|
73 |
):
|
74 |
+
# init_bytes = await init_image.read()
|
75 |
+
init_image = Image.open(BytesIO(init_bytes))
|
76 |
init_image = init_image.convert("RGB").resize((512, 512))
|
77 |
|
78 |
image = request.state.img2img(
|
|
|
93 |
async def inpainting(
|
94 |
request: Request,
|
95 |
prompt: str = Form(...),
|
96 |
+
init_bytes: bytes = Form(...),
|
97 |
+
mask_bytes: bytes = Form(...),
|
98 |
+
num_inference_steps: int = Form(2),
|
99 |
+
strength: float = Form(1.0),
|
100 |
):
|
101 |
+
# init_bytes = await init_image.read()
|
102 |
+
init_image = Image.open(BytesIO(init_bytes))
|
103 |
init_image = init_image.convert("RGB").resize((512, 512))
|
104 |
+
# mask_bytes = await mask_image.read()
|
105 |
+
mask_image = Image.open(BytesIO(mask_bytes))
|
106 |
mask_image = mask_image.convert("RGB").resize((512, 512))
|
107 |
|
108 |
image = request.state.inpaint(
|