This repository contains code to export CRAFT (Character Region Awareness For Text Detection) model to ONNX format and run inference.
If you find this tool useful, consider becoming a sponsor for $1/month and get priority support!
- Docker 🐳
- High-resolution text images 🖼️
├── data/ # Add your high-res images here
├── onnx/ # ONNX model will be exported here
├── weights/ # craft_mlt_25k.pth model goes here
├── outputs/ # Detection results will be saved here
├── Dockerfile
├── onnx-export.py
└── onnx-inference.py
-
Add Images and download pth file 📸
- Place your high-resolution text images in the
data
directory - Download pytorch model from here, and save it in
weights
folder
- Place your high-resolution text images in the
-
Build Docker Image 🔨
docker build -t craft-onnx:latest .
-
Run Docker Container 🐋
docker run -it craft-onnx:latest /bin/bash
-
Export ONNX Model 📤
python3 onnx-export.py
This will:
- Take a sample image from
data
directory - Export ONNX graph to
onnx
folder
- Take a sample image from
-
Run Inference 🔍
python3 onnx-inference.py
- Uses the exported ONNX model
- Saves detection results in
outputs
directory
- Input size: 1280x960
- Optimized for high-resolution document images
- CPU-friendly inference
- Make sure images are readable and have sufficient resolution
- The model works best with clear, well-lit document images
- Check
outputs
directory for detection results
- 🏢 Priority support for integrating this tool into your company's infrastructure
- 🛠️ Direct assistance with project-related issues and customizations
- 💡 Technical consultation for your specific use cases
- 🚀 Early access to new features and improvements
- ⭐ Recognition in our sponsors list
Your sponsorship helps me maintain the code, ensuring it remains a robust and reliable tool for the community. Every contribution, no matter how small, makes a difference!
This repository's modifications and additions are licensed under MIT License.
- CRAFT Text Detector: MIT License
- PyTorch: BSD License
- ONNX Runtime: MIT License
This work builds upon:
- CRAFT-pytorch by CLOVA AI Research
- Other open source projects listed in requirements.txt