DaVinciCode/doctra-document-parser
0
1# Doctra Hugging Face Spaces Deployment Guide2 3## ๐ Quick Deployment4 5### Option 1: Direct Upload to Hugging Face Spaces6 71. **Create a new Space**:8 - Go to [Hugging Face Spaces](https://huggingface.co/spaces)9 - Click "Create new Space"10 - Choose "Gradio" as the SDK11 - Set the title to "Doctra - Document Parser"12 132. **Upload files**:14 - Upload all files from this `hf_space` folder to your Space15 - Make sure `app.py` is in the root directory16 173. **Configure environment**:18 - Go to Settings โ Secrets19 - Add `VLM_API_KEY` if you want to use VLM features20 - Set the value to your API key (OpenAI, Anthropic, Google, etc.)21 22### Option 2: Git Repository Deployment23 241. **Create a Git repository**:25 ```bash26 git init27 git add .28 git commit -m "Initial Doctra HF Space deployment"29 git remote add origin <your-repo-url>30 git push -u origin main31 ```32 332. **Connect to Hugging Face Spaces**:34 - Create a new Space35 - Choose "Git repository" as the source36 - Enter your repository URL37 - Set the app file to `app.py`38 39### Option 3: Docker Deployment40 411. **Build the Docker image**:42 ```bash43 docker build -t doctra-hf-space .44 ```45 462. **Run the container**:47 ```bash48 docker run -p 7860:7860 doctra-hf-space49 ```50 51## ๐ง Configuration52 53### Environment Variables54 55Set these in your Hugging Face Space settings:56 57- `VLM_API_KEY`: Your API key for VLM providers58- `GRADIO_SERVER_NAME`: Server hostname (default: 0.0.0.0)59- `GRADIO_SERVER_PORT`: Server port (default: 7860)60 61### Hardware Requirements62 63- **CPU**: Minimum 2 cores recommended64- **RAM**: Minimum 4GB, 8GB+ recommended65- **Storage**: 10GB+ for models and dependencies66- **GPU**: Optional but recommended for faster processing67 68## ๐ Performance Optimization69 70### For Hugging Face Spaces71 721. **Use CPU-optimized models** when GPU is not available732. **Reduce DPI settings** for faster processing743. **Process smaller documents** to avoid memory issues754. **Enable caching** for repeated operations76 77### For Local Deployment78 791. **Use GPU acceleration** when available802. **Increase memory limits** for large documents813. **Use SSD storage** for better I/O performance824. **Configure proper logging** for debugging83 84## ๐ Troubleshooting85 86### Common Issues87 881. **Import Errors**:89 - Check that all dependencies are in `requirements.txt`90 - Verify Python version compatibility91 922. **Memory Issues**:93 - Reduce DPI settings94 - Process smaller documents95 - Increase available memory96 973. **API Key Issues**:98 - Verify API key is correctly set99 - Check provider-specific requirements100 - Test API connectivity101 1024. **File Upload Issues**:103 - Check file size limits104 - Verify file format support105 - Ensure proper permissions106 107### Debug Mode108 109To enable debug mode, set:110```bash111export GRADIO_DEBUG=1112```113 114## ๐ Monitoring115 116### Health Checks117 118- Monitor CPU and memory usage119- Check disk space availability120- Verify API key validity121- Test document processing pipeline122 123### Logs124 125- Application logs: Check Gradio output126- Error logs: Monitor for exceptions127- Performance logs: Track processing times128- User logs: Monitor usage patterns129 130## ๐ Updates131 132### Updating the Application133 1341. **Code updates**: Push changes to your repository1352. **Dependency updates**: Update `requirements.txt`1363. **Model updates**: Download new model versions1374. **Configuration updates**: Modify environment variables138 139### Version Control140 141- Use semantic versioning142- Tag releases appropriately143- Maintain changelog144- Test before deployment145 146## ๐ก๏ธ Security147 148### Best Practices149 1501. **API Keys**: Store securely, never commit to code1512. **File Uploads**: Validate file types and sizes1523. **Rate Limiting**: Implement to prevent abuse1534. **Input Validation**: Sanitize all user inputs154 155### Privacy156 157- No data is stored permanently158- Files are processed in temporary directories159- API calls are made securely160- User data is not logged161 162## ๐ Support163 164For issues and questions:165 1661. **GitHub Issues**: Report bugs and feature requests1672. **Documentation**: Check the main README.md1683. **Community**: Join discussions on Hugging Face1694. **Email**: Contact the development team170 171## ๐ฏ Next Steps172 173After successful deployment:174 1751. **Test all features** with sample documents1762. **Configure monitoring** and alerting1773. **Set up backups** for important data1784. **Plan for scaling** based on usage1795. **Gather user feedback** for improvements180 