File size: 1,926 Bytes
e219ce4
 
e2be278
e219ce4
 
 
 
 
 
 
e2be278
e219ce4
 
 
e2be278
e219ce4
 
e2be278
e219ce4
 
 
 
e2be278
 
e219ce4
 
e2be278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# FoundationPose Tests

This directory contains test scripts for the FoundationPose HuggingFace API.

## Test Data

Reference images for test objects are stored in `reference/target_cube/`.

## Running Tests

### Test Against HuggingFace Space

```bash
cd /path/to/foundationpose
/path/to/training/.venv/bin/python tests/test_estimator.py
```

The test uses the Gradio client to connect to the deployed API.

## Test Coverage

**test_estimator.py** tests:
1. API client initialization
2. Object initialization via API (reference-based)
3. Pose estimation on query images

## Current Status

**CAD-Based Mode**: ✅ Fully Implemented
- Requires a 3D mesh file (.obj, .stl, .ply)
- Provides accurate 6D pose estimation
- Use the CAD-Based initialization tab in the Gradio interface

**Model-Free Mode**: ⚠️ Not Yet Implemented
- Would require 3D reconstruction from reference images (photogrammetry)
- For now, use photogrammetry tools (Meshroom, COLMAP) to create a mesh first
- Then use CAD-Based mode with the generated mesh

## API Usage

The deployed Space provides two Gradio API endpoints:

### CAD-Based Initialization
```python
from gradio_client import Client, handle_file

client = Client("https://gpue-foundationpose.hf.space")

result = client.predict(
    object_id="my_object",
    mesh_file=handle_file("object.obj"),
    reference_files=[handle_file(f) for f in image_files],  # Optional
    fx=500.0, fy=500.0, cx=320.0, cy=240.0,
    api_name="/gradio_initialize_cad"
)
```

### Pose Estimation
```python
result = client.predict(
    object_id="my_object",
    query_image=handle_file("query.jpg"),
    fx=500.0, fy=500.0, cx=320.0, cy=240.0,
    api_name="/gradio_estimate"
)
```

## Known Issues

1. **Model-Free Mode**: Reference-only initialization is not yet supported. A 3D mesh is required.
2. **Test Results**: Current tests will return "No poses detected" because they don't provide a mesh file.