Spaces:
Running
on
Zero
Running
on
Zero
Upload gradio_app.py with huggingface_hub
Browse files- gradio_app.py +51 -48
gradio_app.py
CHANGED
@@ -207,55 +207,58 @@ def gradio_warped_image(
|
|
207 |
lambda_ts: Float64[torch.Tensor, "n b"] = load_lambda_ts(num_denoise_iters)
|
208 |
progress(0.15, desc="Starting diffusion")
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
static =
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
259 |
|
260 |
# all frames but the first one
|
261 |
frame: np.ndarray
|
|
|
207 |
lambda_ts: Float64[torch.Tensor, "n b"] = load_lambda_ts(num_denoise_iters)
|
208 |
progress(0.15, desc="Starting diffusion")
|
209 |
|
210 |
+
if IN_SPACES:
|
211 |
+
frames: list[PIL.Image.Image] = svd_render(
|
212 |
+
image_o=rgb_resized,
|
213 |
+
masks=masks,
|
214 |
+
cond_image=cond_image,
|
215 |
+
lambda_ts=lambda_ts,
|
216 |
+
num_denoise_iters=num_denoise_iters,
|
217 |
+
weight_clamp=0.2,
|
218 |
+
svd_pipe=SVD_PIPE,
|
219 |
+
)
|
220 |
+
else:
|
221 |
+
# to allow logging from a separate thread
|
222 |
+
log_queue: Queue = Queue()
|
223 |
+
handle = threading.Thread(
|
224 |
+
target=svd_render_threaded,
|
225 |
+
kwargs={
|
226 |
+
"image_o": rgb_resized,
|
227 |
+
"masks": masks,
|
228 |
+
"cond_image": cond_image,
|
229 |
+
"lambda_ts": lambda_ts,
|
230 |
+
"num_denoise_iters": num_denoise_iters,
|
231 |
+
"weight_clamp": 0.2,
|
232 |
+
"svd_pipe": SVD_PIPE,
|
233 |
+
"log_queue": log_queue,
|
234 |
+
},
|
235 |
+
)
|
236 |
|
237 |
+
handle.start()
|
238 |
+
i = 0
|
239 |
+
while True:
|
240 |
+
msg = log_queue.get()
|
241 |
+
match msg:
|
242 |
+
case frames if all(
|
243 |
+
isinstance(frame, PIL.Image.Image) for frame in frames
|
244 |
+
):
|
245 |
+
break
|
246 |
+
case entity_path, entity, times:
|
247 |
+
i += 1
|
248 |
+
rr.reset_time()
|
249 |
+
for timeline, time in times:
|
250 |
+
if isinstance(time, int):
|
251 |
+
rr.set_time_sequence(timeline, time)
|
252 |
+
else:
|
253 |
+
rr.set_time_seconds(timeline, time)
|
254 |
+
static = False
|
255 |
+
if entity_path == "latents":
|
256 |
+
static = True
|
257 |
+
rr.log(entity_path, entity, static=static)
|
258 |
+
yield stream.read(), None, [], f"{i} out of {num_denoise_iters}"
|
259 |
+
case _:
|
260 |
+
assert False
|
261 |
+
handle.join()
|
262 |
|
263 |
# all frames but the first one
|
264 |
frame: np.ndarray
|