lalashechka commited on
Commit
0ac2599
1 Parent(s): 578b424

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -85,10 +85,10 @@ def create_video(prompt, model):
85
  base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
86
 
87
  image_bytes = base64.b64decode(base64_string)
88
- with tempfile.NamedTemporaryFile(delete=True) as temp:
89
- temp.write(image_bytes)
90
- temp_file_path = temp.name
91
- print("cs_1")
92
  except:
93
  print("c_2")
94
  with closing(create_connection(f"{url_sd4}", timeout=120)) as conn:
@@ -100,15 +100,14 @@ def create_video(prompt, model):
100
  conn.recv()
101
  photo = json.loads(conn.recv())['output']['data'][0]
102
  base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
103
-
104
  image_bytes = base64.b64decode(base64_string)
105
- with tempfile.NamedTemporaryFile(delete=True) as temp:
106
- temp.write(image_bytes)
107
- temp_file_path = temp.name
108
- print("cs_2")
109
 
110
  try:
111
- r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": open(temp_file_path, 'rb')})
112
  print(r.text)
113
  hash_ = r.json()['hash']
114
  time.sleep(10)
@@ -138,9 +137,6 @@ def create_video(prompt, model):
138
  #client = Client("https://emmadrex-stable-video-diffusion.hf.space")
139
  #result = client.predict(result1, 0, True, 1, 15, api_name="/video")
140
  #return result[0]['video']
141
-
142
-
143
-
144
 
145
  if model == "AnimateDiff":
146
  data = {"prompt": prompt, "negative_prompt": "EasyNegative"}
 
85
  base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
86
 
87
  image_bytes = base64.b64decode(base64_string)
88
+ #with tempfile.NamedTemporaryFile(delete=False) as temp:
89
+ # temp.write(image_bytes)
90
+ # temp_file_path = temp.name
91
+ # print("cs_1")
92
  except:
93
  print("c_2")
94
  with closing(create_connection(f"{url_sd4}", timeout=120)) as conn:
 
100
  conn.recv()
101
  photo = json.loads(conn.recv())['output']['data'][0]
102
  base64_string = photo.replace('data:image/jpeg;base64,', '').replace('data:image/png;base64,', '')
 
103
  image_bytes = base64.b64decode(base64_string)
104
+ #with tempfile.NamedTemporaryFile(delete=False) as temp:
105
+ # temp.write(image_bytes)
106
+ # temp_file_path = temp.name
107
+ # print("cs_2")
108
 
109
  try:
110
+ r = requests.post("https://stable-video-diffusion.com/api/upload", files={"file": image_bytes})
111
  print(r.text)
112
  hash_ = r.json()['hash']
113
  time.sleep(10)
 
137
  #client = Client("https://emmadrex-stable-video-diffusion.hf.space")
138
  #result = client.predict(result1, 0, True, 1, 15, api_name="/video")
139
  #return result[0]['video']
 
 
 
140
 
141
  if model == "AnimateDiff":
142
  data = {"prompt": prompt, "negative_prompt": "EasyNegative"}