Spaces:
Sleeping
Sleeping
Georg commited on
Commit ·
58e94fa
1
Parent(s): 0467cc6
Prepare job build context
Browse files- Dockerfile +1 -0
- app.py +18 -4
- estimator.py +3 -1
Dockerfile
CHANGED
|
@@ -8,5 +8,6 @@ ENV USE_REAL_MODEL=true
|
|
| 8 |
# Copy application files
|
| 9 |
WORKDIR /app
|
| 10 |
COPY app.py client.py estimator.py masks.py .
|
|
|
|
| 11 |
|
| 12 |
CMD ["python3", "app.py"]
|
|
|
|
| 8 |
# Copy application files
|
| 9 |
WORKDIR /app
|
| 10 |
COPY app.py client.py estimator.py masks.py .
|
| 11 |
+
COPY tests/reference/t_shape /app/tests/reference/t_shape
|
| 12 |
|
| 13 |
CMD ["python3", "app.py"]
|
app.py
CHANGED
|
@@ -22,6 +22,16 @@ import torch
|
|
| 22 |
|
| 23 |
from masks import generate_naive_mask
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
_slimsam_model = None
|
| 26 |
_slimsam_processor = None
|
| 27 |
_slimsam_device = None
|
|
@@ -510,13 +520,15 @@ with gr.Blocks(title="FoundationPose Inference", theme=gr.themes.Soft()) as demo
|
|
| 510 |
cad_mesh_file = gr.File(
|
| 511 |
label="3D Mesh File (.obj, .stl, .ply)",
|
| 512 |
file_count="single",
|
| 513 |
-
file_types=[".obj", ".stl", ".ply", ".mesh"]
|
|
|
|
| 514 |
)
|
| 515 |
|
| 516 |
cad_ref_files = gr.File(
|
| 517 |
label="Reference Images (Optional)",
|
| 518 |
file_count="multiple",
|
| 519 |
-
file_types=["image"]
|
|
|
|
| 520 |
)
|
| 521 |
|
| 522 |
gr.Markdown("### Camera Intrinsics")
|
|
@@ -561,12 +573,14 @@ with gr.Blocks(title="FoundationPose Inference", theme=gr.themes.Soft()) as demo
|
|
| 561 |
|
| 562 |
est_query_image = gr.Image(
|
| 563 |
label="Query Image (RGB)",
|
| 564 |
-
type="numpy"
|
|
|
|
| 565 |
)
|
| 566 |
|
| 567 |
est_depth_image = gr.Image(
|
| 568 |
label="Depth Image (Optional, 16-bit PNG)",
|
| 569 |
-
type="numpy"
|
|
|
|
| 570 |
)
|
| 571 |
|
| 572 |
est_mask_method = gr.Radio(
|
|
|
|
| 22 |
|
| 23 |
from masks import generate_naive_mask
|
| 24 |
|
| 25 |
+
DEFAULT_DATA_DIR = Path("/app/tests/reference/t_shape")
|
| 26 |
+
DEFAULT_MESH = DEFAULT_DATA_DIR / "t_shape.obj"
|
| 27 |
+
DEFAULT_RGB = DEFAULT_DATA_DIR / "rgb_001.jpg"
|
| 28 |
+
DEFAULT_DEPTH = DEFAULT_DATA_DIR / "depth_001.png"
|
| 29 |
+
DEFAULT_REF_IMAGES = [
|
| 30 |
+
DEFAULT_DATA_DIR / "rgb_001.jpg",
|
| 31 |
+
DEFAULT_DATA_DIR / "rgb_002.jpg",
|
| 32 |
+
DEFAULT_DATA_DIR / "rgb_003.jpg",
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
_slimsam_model = None
|
| 36 |
_slimsam_processor = None
|
| 37 |
_slimsam_device = None
|
|
|
|
| 520 |
cad_mesh_file = gr.File(
|
| 521 |
label="3D Mesh File (.obj, .stl, .ply)",
|
| 522 |
file_count="single",
|
| 523 |
+
file_types=[".obj", ".stl", ".ply", ".mesh"],
|
| 524 |
+
value=str(DEFAULT_MESH) if DEFAULT_MESH.exists() else None
|
| 525 |
)
|
| 526 |
|
| 527 |
cad_ref_files = gr.File(
|
| 528 |
label="Reference Images (Optional)",
|
| 529 |
file_count="multiple",
|
| 530 |
+
file_types=["image"],
|
| 531 |
+
value=[str(p) for p in DEFAULT_REF_IMAGES if p.exists()]
|
| 532 |
)
|
| 533 |
|
| 534 |
gr.Markdown("### Camera Intrinsics")
|
|
|
|
| 573 |
|
| 574 |
est_query_image = gr.Image(
|
| 575 |
label="Query Image (RGB)",
|
| 576 |
+
type="numpy",
|
| 577 |
+
value=str(DEFAULT_RGB) if DEFAULT_RGB.exists() else None
|
| 578 |
)
|
| 579 |
|
| 580 |
est_depth_image = gr.Image(
|
| 581 |
label="Depth Image (Optional, 16-bit PNG)",
|
| 582 |
+
type="numpy",
|
| 583 |
+
value=str(DEFAULT_DEPTH) if DEFAULT_DEPTH.exists() else None
|
| 584 |
)
|
| 585 |
|
| 586 |
est_mask_method = gr.Radio(
|
estimator.py
CHANGED
|
@@ -245,7 +245,9 @@ class FoundationPoseEstimator:
|
|
| 245 |
iteration=2 # Fewer iterations for tracking
|
| 246 |
)
|
| 247 |
|
| 248 |
-
# Store pose for next frame
|
|
|
|
|
|
|
| 249 |
obj_data["pose_last"] = pose
|
| 250 |
|
| 251 |
if pose is None:
|
|
|
|
| 245 |
iteration=2 # Fewer iterations for tracking
|
| 246 |
)
|
| 247 |
|
| 248 |
+
# Store pose for next frame (move to CPU if it's a tensor)
|
| 249 |
+
if torch.is_tensor(pose):
|
| 250 |
+
pose = pose.detach().cpu().numpy()
|
| 251 |
obj_data["pose_last"] = pose
|
| 252 |
|
| 253 |
if pose is None:
|