Spaces:
Runtime error
Runtime error
lalashechka
commited on
Commit
•
2aca82a
1
Parent(s):
1bd26d7
Update app.py
Browse files
app.py
CHANGED
@@ -18,9 +18,8 @@ from gradio_client import Client
|
|
18 |
|
19 |
|
20 |
def animate_img(encoded_string):
|
21 |
-
try:
|
22 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(encoded_string, 'rb')})
|
23 |
-
print(r.text)
|
24 |
hash_ = r.json()['hash']
|
25 |
time.sleep(10)
|
26 |
c = 0
|
@@ -37,17 +36,21 @@ def animate_img(encoded_string):
|
|
37 |
sd_video = []
|
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")
|
48 |
client = Client("https://emmadrex-stable-video-diffusion.hf.space")
|
49 |
result = client.predict(result1, 0, True, 1, 15, api_name="/video")
|
50 |
-
|
|
|
|
|
51 |
|
52 |
|
53 |
def create_video(prompt):
|
@@ -69,14 +72,17 @@ def create_video(prompt):
|
|
69 |
break
|
70 |
photo = json.loads(conn.recv())['output']['data'][0][0]
|
71 |
base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
72 |
-
|
73 |
image_bytes = base64.b64decode(base64_string)
|
74 |
with tempfile.NamedTemporaryFile(delete=False) as temp:
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
|
78 |
except:
|
79 |
-
|
|
|
80 |
conn.send('{"fn_index":0,"session_hash":""}')
|
81 |
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":""}}')
|
82 |
conn.recv()
|
@@ -85,11 +91,12 @@ def create_video(prompt):
|
|
85 |
conn.recv()
|
86 |
photo = json.loads(conn.recv())['output']['data'][0]
|
87 |
base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
88 |
-
|
89 |
image_bytes = base64.b64decode(base64_string)
|
90 |
with tempfile.NamedTemporaryFile(delete=False) as temp:
|
91 |
temp.write(image_bytes)
|
92 |
temp_file_path = temp.name
|
|
|
93 |
|
94 |
try:
|
95 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(temp_file_path, 'rb')})
|
|
|
18 |
|
19 |
|
20 |
def animate_img(encoded_string):
|
21 |
+
try:
|
22 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(encoded_string, 'rb')})
|
|
|
23 |
hash_ = r.json()['hash']
|
24 |
time.sleep(10)
|
25 |
c = 0
|
|
|
36 |
sd_video = []
|
37 |
for match in matches:
|
38 |
sd_video.append(f"https://storage.stable-video-diffusion.com/{match}.mp4")
|
|
|
39 |
if len(sd_video) != 0:
|
40 |
+
print("s_1")
|
41 |
return sd_video[0]
|
42 |
else:
|
43 |
_ = 1/0
|
44 |
+
print("f_1")
|
45 |
except:
|
46 |
+
print("2")
|
47 |
client1 = Client("https://emmadrex-stable-video-diffusion.hf.space")
|
48 |
result1 = client1.predict(encoded_string, api_name="/resize_image")
|
49 |
client = Client("https://emmadrex-stable-video-diffusion.hf.space")
|
50 |
result = client.predict(result1, 0, True, 1, 15, api_name="/video")
|
51 |
+
res = result[0]['video']
|
52 |
+
print("s_2")
|
53 |
+
return res
|
54 |
|
55 |
|
56 |
def create_video(prompt):
|
|
|
72 |
break
|
73 |
photo = json.loads(conn.recv())['output']['data'][0][0]
|
74 |
base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
75 |
+
|
76 |
image_bytes = base64.b64decode(base64_string)
|
77 |
with tempfile.NamedTemporaryFile(delete=False) as temp:
|
78 |
+
temp.write(image_bytes)
|
79 |
+
temp_file_path = temp.name
|
80 |
+
print("cs_1")
|
81 |
+
|
82 |
|
83 |
except:
|
84 |
+
print("c_2")
|
85 |
+
with closing(create_connection(f"{url_sd4}", timeout=120)) as conn:
|
86 |
conn.send('{"fn_index":0,"session_hash":""}')
|
87 |
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":""}}')
|
88 |
conn.recv()
|
|
|
91 |
conn.recv()
|
92 |
photo = json.loads(conn.recv())['output']['data'][0]
|
93 |
base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
94 |
+
|
95 |
image_bytes = base64.b64decode(base64_string)
|
96 |
with tempfile.NamedTemporaryFile(delete=False) as temp:
|
97 |
temp.write(image_bytes)
|
98 |
temp_file_path = temp.name
|
99 |
+
print("cs_2")
|
100 |
|
101 |
try:
|
102 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(temp_file_path, 'rb')})
|