Spaces:
Running
on
Zero
Running
on
Zero
pablovela5620
commited on
Commit
•
1bc0980
1
Parent(s):
5fff857
add blueprint for better viewer experience
Browse files
app.py
CHANGED
@@ -17,6 +17,39 @@ model = AsymmetricCroCo3DStereo.from_pretrained(
|
|
17 |
).to(DEVICE)
|
18 |
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
@spaces.GPU
|
21 |
def predict(image_name_list: list[str] | str):
|
22 |
# check if is list or string and if not raise error
|
@@ -38,9 +71,12 @@ def predict(image_name_list: list[str] | str):
|
|
38 |
device=DEVICE,
|
39 |
batch_size=1,
|
40 |
)
|
|
|
|
|
|
|
|
|
41 |
rr.set_time_sequence("sequence", 0)
|
42 |
log_optimized_result(optimized_results, log_path)
|
43 |
-
# blueprint = rrb.Spatial3DView(origin="cube")
|
44 |
rr.save(filename.as_posix())
|
45 |
return filename.as_posix()
|
46 |
|
|
|
17 |
).to(DEVICE)
|
18 |
|
19 |
|
20 |
+
def create_blueprint(image_name_list: list[str], log_path: str) -> rrb.Blueprint:
|
21 |
+
# dont show 2d views if there are more than 4 images as to not clutter the view
|
22 |
+
if len(image_name_list) > 4:
|
23 |
+
blueprint = rrb.Blueprint(
|
24 |
+
rrb.Horizontal(
|
25 |
+
rrb.Spatial3DView(origin=f"{log_path}"),
|
26 |
+
),
|
27 |
+
collapse_panels=True,
|
28 |
+
)
|
29 |
+
else:
|
30 |
+
blueprint = rrb.Blueprint(
|
31 |
+
rrb.Horizontal(
|
32 |
+
contents=[
|
33 |
+
rrb.Spatial3DView(origin=f"{log_path}"),
|
34 |
+
rrb.Vertical(
|
35 |
+
contents=[
|
36 |
+
rrb.Spatial2DView(
|
37 |
+
origin=f"{log_path}/camera_{i}/pinhole/",
|
38 |
+
contents=[
|
39 |
+
"+ $origin/**",
|
40 |
+
],
|
41 |
+
)
|
42 |
+
for i in range(len(image_name_list))
|
43 |
+
]
|
44 |
+
),
|
45 |
+
],
|
46 |
+
column_shares=[3, 1],
|
47 |
+
),
|
48 |
+
collapse_panels=True,
|
49 |
+
)
|
50 |
+
return blueprint
|
51 |
+
|
52 |
+
|
53 |
@spaces.GPU
|
54 |
def predict(image_name_list: list[str] | str):
|
55 |
# check if is list or string and if not raise error
|
|
|
71 |
device=DEVICE,
|
72 |
batch_size=1,
|
73 |
)
|
74 |
+
|
75 |
+
blueprint: rrb.Blueprint = create_blueprint(image_name_list, log_path)
|
76 |
+
rr.send_blueprint(blueprint)
|
77 |
+
|
78 |
rr.set_time_sequence("sequence", 0)
|
79 |
log_optimized_result(optimized_results, log_path)
|
|
|
80 |
rr.save(filename.as_posix())
|
81 |
return filename.as_posix()
|
82 |
|