kingpreyansh commited on
Commit
f5724f4
1 Parent(s): 2c092e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -12,28 +12,28 @@ model = "/home/user/app/sd/stable-diffusion-webui/models/Stable-diffusion/"
12
 
13
  #os.system(python /home/user/app/sd/stable-diffusion-webui/webui.py)
14
 
15
- # url = "http://127.0.0.1:7861"
16
 
17
- # payload = {
18
- # "prompt": "apple is beautiful",
19
- # "steps": 5
20
- # }
21
 
22
- # response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload)
23
 
24
- # r = response.json()
25
 
26
- # for i in r['images']:
27
- # image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
28
 
29
- # png_payload = {
30
- # "image": "data:image/png;base64," + i
31
- # }
32
- # response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
33
 
34
- # pnginfo = PngImagePlugin.PngInfo()
35
- # pnginfo.add_text("parameters", response2.json().get("info"))
36
- # image.save('output.png', pnginfo=pnginfo)
37
 
38
  import psutil
39
 
 
12
 
13
  #os.system(python /home/user/app/sd/stable-diffusion-webui/webui.py)
14
 
15
+ url = "http://0.0.0.0:7860"
16
 
17
+ payload = {
18
+ "prompt": "apple is beautiful",
19
+ "steps": 5
20
+ }
21
 
22
+ response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload)
23
 
24
+ r = response.json()
25
 
26
+ for i in r['images']:
27
+ image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
28
 
29
+ png_payload = {
30
+ "image": "data:image/png;base64," + i
31
+ }
32
+ response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
33
 
34
+ pnginfo = PngImagePlugin.PngInfo()
35
+ pnginfo.add_text("parameters", response2.json().get("info"))
36
+ image.save('output.png', pnginfo=pnginfo)
37
 
38
  import psutil
39