lalashechka commited on
Commit
789c5b7
1 Parent(s): 0e406cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -40,9 +40,9 @@ def animate_img(encoded_string):
40
  print(sd_video[0])
41
  return sd_video[0]
42
  except:
43
- client1 = Client("https://emmadrex-stable-video-diffusion.hf.space/--replicas/c2gnj/")
44
  result1 = client1.predict(encoded_string, api_name="/resize_image")
45
- client = Client("https://emmadrex-stable-video-diffusion.hf.space/--replicas/c2gnj/")
46
  result = client.predict(result1, 0, True, 1, 15, api_name="/video")
47
  return result[0]['video']
48
 
@@ -55,9 +55,12 @@ def create_video(prompt):
55
  with closing(create_connection(f"{url_sd3}", timeout=120)) as conn:
56
  conn.send('{"fn_index":3,"session_hash":""}')
57
  conn.send(f'{{"data":["{prompt}","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",7.5,"(No style)"],"event_data":null,"fn_index":3,"session_hash":""}}')
58
- while True:
 
59
  status = json.loads(conn.recv())['msg']
60
  if status == 'estimation':
 
 
61
  continue
62
  if status == 'process_starts':
63
  break
@@ -78,7 +81,7 @@ def create_video(prompt):
78
  conn.recv()
79
  conn.recv()
80
  photo = json.loads(conn.recv())['output']['data'][0]
81
- photo = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
82
 
83
  image_bytes = base64.b64decode(base64_string)
84
  with tempfile.NamedTemporaryFile(delete=False) as temp:
@@ -107,9 +110,9 @@ def create_video(prompt):
107
  print(sd_video[0])
108
  return sd_video[0]
109
  except:
110
- client1 = Client("https://emmadrex-stable-video-diffusion.hf.space/--replicas/c2gnj/")
111
  result1 = client1.predict(encoded_string, api_name="/resize_image")
112
- client = Client("https://emmadrex-stable-video-diffusion.hf.space/--replicas/c2gnj/")
113
  result = client.predict(result1, 0, True, 1, 15, api_name="/video")
114
  return result[0]['video']
115
 
 
40
  print(sd_video[0])
41
  return sd_video[0]
42
  except:
43
+ client1 = Client("https://emmadrex-stable-video-diffusion.hf.space")
44
  result1 = client1.predict(encoded_string, api_name="/resize_image")
45
+ client = Client("https://emmadrex-stable-video-diffusion.hf.space")
46
  result = client.predict(result1, 0, True, 1, 15, api_name="/video")
47
  return result[0]['video']
48
 
 
55
  with closing(create_connection(f"{url_sd3}", timeout=120)) as conn:
56
  conn.send('{"fn_index":3,"session_hash":""}')
57
  conn.send(f'{{"data":["{prompt}","[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",7.5,"(No style)"],"event_data":null,"fn_index":3,"session_hash":""}}')
58
+ c = 0
59
+ while c < 45:
60
  status = json.loads(conn.recv())['msg']
61
  if status == 'estimation':
62
+ c += 1
63
+ time.sleep(1)
64
  continue
65
  if status == 'process_starts':
66
  break
 
81
  conn.recv()
82
  conn.recv()
83
  photo = json.loads(conn.recv())['output']['data'][0]
84
+ base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
85
 
86
  image_bytes = base64.b64decode(base64_string)
87
  with tempfile.NamedTemporaryFile(delete=False) as temp:
 
110
  print(sd_video[0])
111
  return sd_video[0]
112
  except:
113
+ client1 = Client("https://emmadrex-stable-video-diffusion.hf.space")
114
  result1 = client1.predict(encoded_string, api_name="/resize_image")
115
+ client = Client("https://emmadrex-stable-video-diffusion.hf.space")
116
  result = client.predict(result1, 0, True, 1, 15, api_name="/video")
117
  return result[0]['video']
118