Spaces:
Sleeping
Sleeping
Commit
•
35b6d9d
1
Parent(s):
34c96bd
fix pickle error
Browse files
app.py
CHANGED
@@ -168,31 +168,37 @@ def pipeline_callback(output_queue: SimpleQueue, pipe: Any, step_index: int, tim
|
|
168 |
return callback_kwargs
|
169 |
|
170 |
@spaces.GPU
|
171 |
-
def generate_mvs(
|
172 |
|
173 |
seed_everything(sample_seed)
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
|
181 |
-
output_queue
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
194 |
|
195 |
-
# return z123_image, show_image
|
196 |
|
197 |
@spaces.GPU
|
198 |
def make3d(output_queue: SimpleQueue, images: Image.Image):
|
@@ -292,13 +298,25 @@ def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
|
|
292 |
|
293 |
yield stream.read()
|
294 |
|
295 |
-
output_queue = SimpleQueue()
|
296 |
|
297 |
-
mvs_thread = threading.Thread(target=generate_mvs, args=[output_queue, input_image, sample_steps, sample_seed])
|
298 |
-
mvs_thread.start()
|
299 |
|
300 |
-
while True:
|
301 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
if msg[0] == "z123_image":
|
303 |
z123_image = msg[1]
|
304 |
break
|
@@ -307,8 +325,6 @@ def log_to_rr(input_image, do_remove_background, sample_steps, sample_seed):
|
|
307 |
entity = msg[2]
|
308 |
rr.log(entity_path, entity)
|
309 |
yield stream.read()
|
310 |
-
|
311 |
-
mvs_thread.join()
|
312 |
|
313 |
rr.log("z123image", rr.Image(z123_image))
|
314 |
yield stream.read()
|
|
|
168 |
return callback_kwargs
|
169 |
|
170 |
@spaces.GPU
|
171 |
+
def generate_mvs(input_image, sample_steps, sample_seed):
|
172 |
|
173 |
seed_everything(sample_seed)
|
174 |
|
175 |
+
def thread_target(output_queue, input_image, sample_steps):
|
176 |
+
z123_image = pipeline(
|
177 |
+
input_image,
|
178 |
+
num_inference_steps=sample_steps,
|
179 |
+
callback_on_step_end=lambda *args, **kwargs: pipeline_callback(output_queue, *args, **kwargs),
|
180 |
+
).images[0]
|
181 |
+
output_queue.put(("z123_image", z123_image))
|
182 |
|
183 |
+
output_queue = SimpleQueue()
|
184 |
+
z123_thread = threading.Thread(
|
185 |
+
target=thread_target,
|
186 |
+
args=
|
187 |
+
[
|
188 |
+
output_queue,
|
189 |
+
input_image,
|
190 |
+
sample_steps,
|
191 |
+
]
|
192 |
+
)
|
193 |
+
z123_thread.start()
|
194 |
|
195 |
+
while True:
|
196 |
+
msg = output_queue.get()
|
197 |
+
yield msg
|
198 |
+
if msg[0] == "z123_image":
|
199 |
+
break
|
200 |
+
z123_thread.join()
|
201 |
|
|
|
202 |
|
203 |
@spaces.GPU
|
204 |
def make3d(output_queue: SimpleQueue, images: Image.Image):
|
|
|
298 |
|
299 |
yield stream.read()
|
300 |
|
301 |
+
# output_queue = SimpleQueue()
|
302 |
|
303 |
+
# mvs_thread = threading.Thread(target=generate_mvs, args=[output_queue, input_image, sample_steps, sample_seed])
|
304 |
+
# mvs_thread.start()
|
305 |
|
306 |
+
# while True:
|
307 |
+
# msg = output_queue.get()
|
308 |
+
# if msg[0] == "z123_image":
|
309 |
+
# z123_image = msg[1]
|
310 |
+
# break
|
311 |
+
# elif msg[0] == "log":
|
312 |
+
# entity_path = msg[1]
|
313 |
+
# entity = msg[2]
|
314 |
+
# rr.log(entity_path, entity)
|
315 |
+
# yield stream.read()
|
316 |
+
|
317 |
+
# mvs_thread.join()
|
318 |
+
|
319 |
+
for msg in generate_mvs(input_image, sample_steps, sample_seed):
|
320 |
if msg[0] == "z123_image":
|
321 |
z123_image = msg[1]
|
322 |
break
|
|
|
325 |
entity = msg[2]
|
326 |
rr.log(entity_path, entity)
|
327 |
yield stream.read()
|
|
|
|
|
328 |
|
329 |
rr.log("z123image", rr.Image(z123_image))
|
330 |
yield stream.read()
|