Spaces:
Sleeping
Sleeping
toilaluan
commited on
Commit
·
ef39184
1
Parent(s):
6b48430
abc
Browse files
app.py
CHANGED
|
@@ -5,6 +5,13 @@ import io
|
|
| 5 |
import base64
|
| 6 |
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def generate_image(
|
| 9 |
prompt, seed, width, height, num_inference_steps, model_name, guidance_scale, key
|
| 10 |
):
|
|
@@ -21,11 +28,11 @@ def generate_image(
|
|
| 21 |
},
|
| 22 |
}
|
| 23 |
response = requests.post(
|
| 24 |
-
"http://proxy_client_nicheimage.nichetensor.com:10003
|
| 25 |
)
|
| 26 |
base64_image = response.json()
|
| 27 |
-
|
| 28 |
-
image =
|
| 29 |
return image
|
| 30 |
|
| 31 |
|
|
@@ -34,11 +41,17 @@ iface = gr.Interface(
|
|
| 34 |
inputs=[
|
| 35 |
"text",
|
| 36 |
gr.Number(value=0),
|
| 37 |
-
gr.
|
| 38 |
-
gr.
|
| 39 |
-
gr.
|
| 40 |
gr.Dropdown(choices=["RealisticVision", "SDXLTurbo"], value="RealisticVision"),
|
| 41 |
-
gr.Slider(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
"text",
|
| 43 |
],
|
| 44 |
outputs="image",
|
|
@@ -46,4 +59,4 @@ iface = gr.Interface(
|
|
| 46 |
description="Enter a prompt to generate an image.",
|
| 47 |
)
|
| 48 |
|
| 49 |
-
iface.queue().launch()
|
|
|
|
| 5 |
import base64
|
| 6 |
|
| 7 |
|
| 8 |
+
def base64_to_pil_image(base64_image: str) -> Image.Image:
|
| 9 |
+
image_stream = io.BytesIO(base64.b64decode(base64_image))
|
| 10 |
+
image = Image.open(image_stream)
|
| 11 |
+
|
| 12 |
+
return image
|
| 13 |
+
|
| 14 |
+
|
| 15 |
def generate_image(
|
| 16 |
prompt, seed, width, height, num_inference_steps, model_name, guidance_scale, key
|
| 17 |
):
|
|
|
|
| 28 |
},
|
| 29 |
}
|
| 30 |
response = requests.post(
|
| 31 |
+
"http://proxy_client_nicheimage.nichetensor.com:10003/generate", json=data
|
| 32 |
)
|
| 33 |
base64_image = response.json()
|
| 34 |
+
print(base64_image)
|
| 35 |
+
image = base64_to_pil_image(base64_image)
|
| 36 |
return image
|
| 37 |
|
| 38 |
|
|
|
|
| 41 |
inputs=[
|
| 42 |
"text",
|
| 43 |
gr.Number(value=0),
|
| 44 |
+
gr.Slider(label="Width", minimum=0, maximum=2048, value=512, step=64),
|
| 45 |
+
gr.Slider(label="Height", minimum=0, maximum=2048, value=512, step=64),
|
| 46 |
+
gr.Slider(label="Inference Steps", minimum=0, maximum=50, value=30, step=1),
|
| 47 |
gr.Dropdown(choices=["RealisticVision", "SDXLTurbo"], value="RealisticVision"),
|
| 48 |
+
gr.Slider(
|
| 49 |
+
label="Guidance Scale",
|
| 50 |
+
minimum=0,
|
| 51 |
+
maximum=1,
|
| 52 |
+
value=7,
|
| 53 |
+
step=0.1,
|
| 54 |
+
),
|
| 55 |
"text",
|
| 56 |
],
|
| 57 |
outputs="image",
|
|
|
|
| 59 |
description="Enter a prompt to generate an image.",
|
| 60 |
)
|
| 61 |
|
| 62 |
+
iface.queue().launch(share=False)
|