Spaces:
Runtime error
Runtime error
lalashechka
commited on
Commit
•
d4317be
1
Parent(s):
d5d5662
Update app.py
Browse files
app.py
CHANGED
@@ -90,21 +90,24 @@ def create_video(prompt, model):
|
|
90 |
# temp_file_path = temp.name
|
91 |
# print("cs_1")
|
92 |
except:
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
|
109 |
try:
|
110 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": image_bytes})
|
|
|
90 |
# temp_file_path = temp.name
|
91 |
# print("cs_1")
|
92 |
except:
|
93 |
+
try:
|
94 |
+
print("c_2")
|
95 |
+
with closing(create_connection(f"{url_sd4}", timeout=120)) as conn:
|
96 |
+
conn.send('{"fn_index":0,"session_hash":""}')
|
97 |
+
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":""}}')
|
98 |
+
conn.recv()
|
99 |
+
conn.recv()
|
100 |
+
conn.recv()
|
101 |
+
conn.recv()
|
102 |
+
photo = json.loads(conn.recv())['output']['data'][0]
|
103 |
+
base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
|
104 |
+
image_bytes = base64.b64decode(base64_string)
|
105 |
+
#with tempfile.NamedTemporaryFile(delete=False) as temp:
|
106 |
+
# temp.write(image_bytes)
|
107 |
+
# temp_file_path = temp.name
|
108 |
+
# print("cs_2")
|
109 |
+
except:
|
110 |
+
return None
|
111 |
|
112 |
try:
|
113 |
r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": image_bytes})
|