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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -28,7 +28,7 @@ def animate_img(encoded_string):
28
  r2 = requests.get(f"https://stable-video-diffusion.com/result?hash={hash_}")
29
  source_string = r2.text
30
  if "Generation has been in progress for" in source_string:
31
- time.sleep(10)
32
  c += 1
33
  continue
34
  if "Generation has been in progress for" not in source_string:
@@ -38,7 +38,10 @@ def animate_img(encoded_string):
38
  for match in matches:
39
  sd_video.append(f"https://storage.stable-video-diffusion.com/{match}.mp4")
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")
@@ -56,7 +59,7 @@ def create_video(prompt):
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
@@ -98,7 +101,7 @@ def create_video(prompt):
98
  r2 = requests.get(f"https://stable-video-diffusion.com/result?hash={hash_}")
99
  source_string = r2.text
100
  if "Generation has been in progress for" in source_string:
101
- time.sleep(10)
102
  c += 1
103
  continue
104
  if "Generation has been in progress for" not in source_string:
@@ -108,7 +111,10 @@ def create_video(prompt):
108
  for match in matches:
109
  sd_video.append(f"https://storage.stable-video-diffusion.com/{match}.mp4")
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")
 
28
  r2 = requests.get(f"https://stable-video-diffusion.com/result?hash={hash_}")
29
  source_string = r2.text
30
  if "Generation has been in progress for" in source_string:
31
+ time.sleep(15)
32
  c += 1
33
  continue
34
  if "Generation has been in progress for" not in source_string:
 
38
  for match in matches:
39
  sd_video.append(f"https://storage.stable-video-diffusion.com/{match}.mp4")
40
  print(sd_video[0])
41
+ if len(sd_video) != 0:
42
+ return sd_video[0]
43
+ else:
44
+ _ = 1/0
45
  except:
46
  client1 = Client("https://emmadrex-stable-video-diffusion.hf.space")
47
  result1 = client1.predict(encoded_string, api_name="/resize_image")
 
59
  conn.send('{"fn_index":3,"session_hash":""}')
60
  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":""}}')
61
  c = 0
62
+ while c < 60:
63
  status = json.loads(conn.recv())['msg']
64
  if status == 'estimation':
65
  c += 1
 
101
  r2 = requests.get(f"https://stable-video-diffusion.com/result?hash={hash_}")
102
  source_string = r2.text
103
  if "Generation has been in progress for" in source_string:
104
+ time.sleep(15)
105
  c += 1
106
  continue
107
  if "Generation has been in progress for" not in source_string:
 
111
  for match in matches:
112
  sd_video.append(f"https://storage.stable-video-diffusion.com/{match}.mp4")
113
  print(sd_video[0])
114
+ if len(sd_video) != 0:
115
+ return sd_video[0]
116
+ else:
117
+ _ = 1/0
118
  except:
119
  client1 = Client("https://emmadrex-stable-video-diffusion.hf.space")
120
  result1 = client1.predict(encoded_string, api_name="/resize_image")