xizaoqu
commited on
Commit
·
e5d4346
1
Parent(s):
254ff82
update
Browse files
app.py
CHANGED
@@ -157,6 +157,15 @@ def save_video(frames, path="output.mp4", fps=10):
|
|
157 |
subprocess.run(ffmpeg_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
158 |
return path
|
159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
@hydra.main(
|
161 |
version_base=None,
|
162 |
config_path="configurations",
|
@@ -172,15 +181,17 @@ def run(cfg: DictConfig):
|
|
172 |
|
173 |
memory_frames.append(load_image_as_tensor(DEFAULT_IMAGE))
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
184 |
|
185 |
def set_denoising_steps(denoising_steps, sampling_timesteps_state):
|
186 |
algo.sampling_timesteps = denoising_steps
|
@@ -198,11 +209,20 @@ def run(cfg: DictConfig):
|
|
198 |
|
199 |
for i in range(len(actions)):
|
200 |
memory_curr_frame += 1
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
memory_frames.append(new_frame)
|
208 |
|
@@ -230,11 +250,20 @@ def run(cfg: DictConfig):
|
|
230 |
memory_curr_frame = 0
|
231 |
input_history = ""
|
232 |
|
233 |
-
_ = run_interactive(memory_frames[0],
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
return input_history, DEFAULT_IMAGE
|
239 |
|
240 |
def on_image_click(SELECTED_IMAGE):
|
@@ -243,11 +272,13 @@ def run(cfg: DictConfig):
|
|
243 |
reset()
|
244 |
return SELECTED_IMAGE
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
251 |
|
252 |
print("first algo frame:", len(algo.frames))
|
253 |
|
|
|
157 |
subprocess.run(ffmpeg_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
158 |
return path
|
159 |
|
160 |
+
class InteractiveRunner:
|
161 |
+
def __init__(self, algo):
|
162 |
+
self.algo = algo
|
163 |
+
|
164 |
+
@spaces.GPU()
|
165 |
+
def run(self, first_frame, action, first_pose, curr_frame, device):
|
166 |
+
return self.algo.interactive(first_frame, action, first_pose, curr_frame, device=device)
|
167 |
+
|
168 |
+
|
169 |
@hydra.main(
|
170 |
version_base=None,
|
171 |
config_path="configurations",
|
|
|
181 |
|
182 |
memory_frames.append(load_image_as_tensor(DEFAULT_IMAGE))
|
183 |
|
184 |
+
runner = InteractiveRunner(algo)
|
185 |
+
|
186 |
+
# @spaces.GPU()
|
187 |
+
# def run_interactive(first_frame, action, first_pose, curr_frame, device):
|
188 |
+
# global algo
|
189 |
+
# new_frame = algo.interactive(first_frame,
|
190 |
+
# action,
|
191 |
+
# first_pose,
|
192 |
+
# curr_frame,
|
193 |
+
# device=device)
|
194 |
+
# return new_frame
|
195 |
|
196 |
def set_denoising_steps(denoising_steps, sampling_timesteps_state):
|
197 |
algo.sampling_timesteps = denoising_steps
|
|
|
209 |
|
210 |
for i in range(len(actions)):
|
211 |
memory_curr_frame += 1
|
212 |
+
|
213 |
+
# new_frame = run_interactive(memory_frames[0],
|
214 |
+
# actions[i],
|
215 |
+
# None,
|
216 |
+
# memory_curr_frame,
|
217 |
+
# device=device)
|
218 |
+
|
219 |
+
new_frame = runner.run(
|
220 |
+
memory_frames[0],
|
221 |
+
actions[i],
|
222 |
+
None,
|
223 |
+
memory_curr_frame,
|
224 |
+
device
|
225 |
+
)
|
226 |
|
227 |
memory_frames.append(new_frame)
|
228 |
|
|
|
250 |
memory_curr_frame = 0
|
251 |
input_history = ""
|
252 |
|
253 |
+
# _ = run_interactive(memory_frames[0],
|
254 |
+
# actions[0],
|
255 |
+
# poses[0],
|
256 |
+
# memory_curr_frame,
|
257 |
+
# device=device)
|
258 |
+
|
259 |
+
new_frame = runner.run(
|
260 |
+
memory_frames[0],
|
261 |
+
actions[0],
|
262 |
+
poses[0],
|
263 |
+
memory_curr_frame,
|
264 |
+
device
|
265 |
+
)
|
266 |
+
|
267 |
return input_history, DEFAULT_IMAGE
|
268 |
|
269 |
def on_image_click(SELECTED_IMAGE):
|
|
|
272 |
reset()
|
273 |
return SELECTED_IMAGE
|
274 |
|
275 |
+
new_frame = runner.run(
|
276 |
+
memory_frames[0],
|
277 |
+
actions[0],
|
278 |
+
poses[0],
|
279 |
+
memory_curr_frame,
|
280 |
+
device
|
281 |
+
)
|
282 |
|
283 |
print("first algo frame:", len(algo.frames))
|
284 |
|