Spaces:
Runtime error
Runtime error
kingpreyansh
commited on
Commit
•
a97414f
1
Parent(s):
1c23be1
Update app.py
Browse files
app.py
CHANGED
@@ -11,41 +11,41 @@ from PIL import Image, PngImagePlugin
|
|
11 |
|
12 |
model = "/home/user/app/sd/stable-diffusion-webui/models/Stable-diffusion/"
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
##############################################################################################
|
42 |
|
43 |
-
def current_working_directoy(cwd, ldir, python_path):
|
44 |
-
|
45 |
|
46 |
-
iface = gr.Interface(fn=current_working_directoy,
|
47 |
|
48 |
-
inputs=["text", "text", "text"], outputs=["text", "text", "text"])
|
49 |
|
50 |
|
51 |
-
iface.launch()
|
|
|
11 |
|
12 |
model = "/home/user/app/sd/stable-diffusion-webui/models/Stable-diffusion/"
|
13 |
|
14 |
+
os.system(/use/bin/python3 /home/user/app/sd/stable-diffusion-webui/webui.py)
|
15 |
|
16 |
+
url = "http://0.0.0.0:7860"
|
17 |
|
18 |
+
payload = {
|
19 |
+
"prompt": "apple is beautiful",
|
20 |
+
"steps": 5
|
21 |
+
}
|
22 |
|
23 |
|
24 |
+
sleep(5)
|
25 |
+
response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload)
|
26 |
|
27 |
+
r = response.json()
|
28 |
|
29 |
+
for i in r['images']:
|
30 |
+
image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
|
31 |
|
32 |
+
png_payload = {
|
33 |
+
"image": "data:image/png;base64," + i
|
34 |
+
}
|
35 |
+
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
36 |
|
37 |
+
pnginfo = PngImagePlugin.PngInfo()
|
38 |
+
pnginfo.add_text("parameters", response2.json().get("info"))
|
39 |
+
image.save('output.png', pnginfo=pnginfo)
|
40 |
|
41 |
##############################################################################################
|
42 |
|
43 |
+
# def current_working_directoy(cwd, ldir, python_path):
|
44 |
+
# return os.getcwd(), psutil.net_connections(), os.listdir('/usr/bin')
|
45 |
|
46 |
+
# iface = gr.Interface(fn=current_working_directoy,
|
47 |
|
48 |
+
# inputs=["text", "text", "text"], outputs=["text", "text", "text"])
|
49 |
|
50 |
|
51 |
+
# iface.launch()
|