able to convert onnx to blob
This commit is contained in:
@ -874,14 +874,29 @@ class AnnotationApp:
|
||||
return "✓ Training process terminated"
|
||||
return "⚠️ No training in progress"
|
||||
|
||||
def export_for_oak_d(self, model_path: str, output_dir: str = "oak_d_export", img_size: int = 640):
|
||||
def get_model_path_from_display(self, model_display: str) -> Path | None:
|
||||
"""Get the actual model path from a display name."""
|
||||
if not hasattr(self, 'available_models') or not self.available_models:
|
||||
return None
|
||||
|
||||
for model in self.available_models:
|
||||
if model['display'] == model_display:
|
||||
return model['path']
|
||||
|
||||
return None
|
||||
|
||||
def export_for_oak_d(self, model_display: str, output_dir: str = "oak_d_export", img_size: int = 640):
|
||||
"""Export trained model for OAK-D camera deployment."""
|
||||
try:
|
||||
weights_path = Path(model_path)
|
||||
# Convert display name to actual path
|
||||
weights_path = self.get_model_path_from_display(model_display)
|
||||
if not weights_path:
|
||||
return f"❌ Model '{model_display}' not found. Try clicking '🔍 Scan for Models' first."
|
||||
|
||||
output_path = Path(output_dir)
|
||||
|
||||
if not weights_path.exists():
|
||||
return "❌ Model weights not found"
|
||||
return f"❌ Model weights not found at: {weights_path}"
|
||||
|
||||
output_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@ -951,7 +966,19 @@ class AnnotationApp:
|
||||
|
||||
except Exception as e:
|
||||
# OpenVINO not available, just return ONNX
|
||||
return f"✓ {model_type.upper()} exported to ONNX!\n📁 Output: {output_path}\n🔗 Next: Convert ONNX to blob using blobconverter.luxonis.com\n⚠️ OpenVINO not available: {str(e)}"
|
||||
import shutil
|
||||
docker_hint = ""
|
||||
if shutil.which("docker") is None:
|
||||
docker_hint = "\n⚠️ Docker not found (needed for offline conversion via ModelConverter)."
|
||||
return (
|
||||
f"✓ {model_type.upper()} exported to ONNX!\n"
|
||||
f"📁 Output: {output_path}\n"
|
||||
f"🔗 Next: Convert ONNX → RVC using HubAI (online) or ModelConverter (offline).\n"
|
||||
f"Docs: https://docs.luxonis.com/software-v3/ai-inference/conversion/\n"
|
||||
f"💡 Offline conversion: Use Luxonis ModelConverter with Docker\n"
|
||||
f"⚠️ OpenVINO export not available: {str(e)}"
|
||||
f"{docker_hint}"
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return f"❌ Export failed: {str(e)}"
|
||||
@ -1178,19 +1205,18 @@ def create_ui(app: AnnotationApp) -> gr.Blocks:
|
||||
python -c "from openvino.runtime import Core; core = Core(); model = core.read_model('model.xml'); print('✓ Model loaded')"
|
||||
```
|
||||
|
||||
2. **Convert to Blob**:
|
||||
- Go to: https://blobconverter.luxonis.com/
|
||||
- Upload your `.xml` and `.bin` files
|
||||
- Select OAK-D device
|
||||
- Download the `.blob` file
|
||||
2. **Convert to RVC compiled format** (recommended by Luxonis):
|
||||
- Online: HubAI conversion (fastest setup)
|
||||
- Offline: ModelConverter (requires Docker)
|
||||
- Docs: https://docs.luxonis.com/software-v3/ai-inference/conversion/
|
||||
|
||||
3. **Deploy to OAK-D**:
|
||||
- Use DepthAI Python API
|
||||
- Or use OAK-D examples with your blob
|
||||
|
||||
### 💡 Tips
|
||||
- Use **FP32** for best accuracy (default)
|
||||
- **Nano models** work best on edge devices
|
||||
- If you quantize, use real calibration images for best accuracy
|
||||
- Test inference speed vs accuracy trade-off
|
||||
""")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user