Spaces:
Runtime error
Runtime error
kingpreyansh
commited on
Commit
•
fe00933
1
Parent(s):
e39404e
Update app.py
Browse files
app.py
CHANGED
@@ -3,4 +3,36 @@ import os
|
|
3 |
|
4 |
model = "/home/user/app/sd/stable-diffusion-webui/models/Stable-diffusion/"
|
5 |
|
6 |
-
os.system(python /home/user/app/sd/stable-diffusion-webui/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt "$model" --xformers $auth --disable-console-progressbars)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
model = "/home/user/app/sd/stable-diffusion-webui/models/Stable-diffusion/"
|
5 |
|
6 |
+
os.system(python /home/user/app/sd/stable-diffusion-webui/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt "$model" --xformers $auth --disable-console-progressbars)
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
import json
|
12 |
+
import requests
|
13 |
+
import io
|
14 |
+
import base64
|
15 |
+
from PIL import Image, PngImagePlugin
|
16 |
+
|
17 |
+
url = "http://127.0.0.1:7861"
|
18 |
+
|
19 |
+
payload = {
|
20 |
+
"prompt": "apple is beautiful",
|
21 |
+
"steps": 5
|
22 |
+
}
|
23 |
+
|
24 |
+
response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload)
|
25 |
+
|
26 |
+
r = response.json()
|
27 |
+
|
28 |
+
for i in r['images']:
|
29 |
+
image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
|
30 |
+
|
31 |
+
png_payload = {
|
32 |
+
"image": "data:image/png;base64," + i
|
33 |
+
}
|
34 |
+
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
35 |
+
|
36 |
+
pnginfo = PngImagePlugin.PngInfo()
|
37 |
+
pnginfo.add_text("parameters", response2.json().get("info"))
|
38 |
+
image.save('output.png', pnginfo=pnginfo)
|