lalashechka commited on
Commit
6f5608c
1 Parent(s): c1df027

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -45,7 +45,7 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
45
  file_name = response.json()['image']['file_name']
46
  photo = f"https://huggingface.co/datasets/enzostvs/stable-diffusion-tpu-generations/resolve/main/images/{file_name}.png"
47
  return photo
48
- except:
49
  try:
50
  print('n_1')
51
  with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
@@ -61,20 +61,20 @@ def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
61
  photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
62
  photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
63
  return photo
64
- except:
65
- print("n_2")
66
- print(url_sd4)
67
- with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
68
- conn.send('{"fn_index":0,"session_hash":""}')
69
- conn.send(f'{{"data":["{prompt}","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry","dreamshaperXL10_alpha2.safetensors [c8afe2ef]",30,"DPM++ 2M Karras",7,1024,1024,-1],"event_data":null,"fn_index":0,"session_hash":""}}')
70
- conn.recv()
71
- conn.recv()
72
- conn.recv()
73
- conn.recv()
74
- photo = json.loads(conn.recv())['output']['data'][0]
75
- photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
76
- photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
77
- return photo
78
 
79
 
80
  def flipp():
 
45
  file_name = response.json()['image']['file_name']
46
  photo = f"https://huggingface.co/datasets/enzostvs/stable-diffusion-tpu-generations/resolve/main/images/{file_name}.png"
47
  return photo
48
+ except:
49
  try:
50
  print('n_1')
51
  with closing(create_connection(f"{url_sd3}", timeout=60)) as conn:
 
61
  photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
62
  photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
63
  return photo
64
+ except:
65
+ print("n_2")
66
+ print(url_sd4)
67
+ with closing(create_connection(f"{url_sd4}", timeout=60)) as conn:
68
+ conn.send('{"fn_index":0,"session_hash":""}')
69
+ conn.send(f'{{"data":["{prompt}","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry","dreamshaperXL10_alpha2.safetensors [c8afe2ef]",30,"DPM++ 2M Karras",7,1024,1024,-1],"event_data":null,"fn_index":0,"session_hash":""}}')
70
+ conn.recv()
71
+ conn.recv()
72
+ conn.recv()
73
+ conn.recv()
74
+ photo = json.loads(conn.recv())['output']['data'][0]
75
+ photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
76
+ photo = Image.open(io.BytesIO(base64.decodebytes(bytes(photo, "utf-8"))))
77
+ return photo
78
 
79
 
80
  def flipp():