--- title: Convert to ONNX emoji: ☯ colorFrom: indigo colorTo: yellow sdk: streamlit sdk_version: 1.40.1 app_file: app.py pinned: true license: apache-2.0 short_description: Convert a Hugging Face model to ONNX format --- # Convert to ONNX ## Overview This project provides a Streamlit application that converts Hugging Face models to ONNX (Open Neural Network Exchange) format, enabling broader model compatibility and deployment options. The application streamlines the process of downloading, converting, and uploading models to Hugging Face. ## Features - **One-Click Model Conversion**: Convert Hugging Face models to ONNX format with minimal configuration - **User-Friendly Interface**: Intuitive Streamlit-based web interface - **Quantization Support**: Automatic model quantization for reduced size and faster inference ## Prerequisites - Python 3.8+ - Hugging Face account and API token - Git ## Installation 1. Clone the repository: ```bash git clone https://huggingface.co/spaces/onnx-community/convert-to-onnx cd convert-to-onnx ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Configure Hugging Face credentials: ```bash # Option 1: Environment variables export HF_TOKEN="your_token" # Option 2: Create .streamlit/secrets.toml echo 'HF_TOKEN = "your_token"' > .streamlit/secrets.toml ``` ## Usage 1. Start the application: ```bash streamlit run app.py ``` 2. Access the web interface at `http://localhost:8501` 3. Enter a Hugging Face model ID (e.g., `EleutherAI/pythia-14m`) 4. Click "Proceed" to start the conversion The converted model will be available in your Hugging Face account as `{username}/{model-name}-ONNX`. ## Development ### Contributing 1. Fork the repository 2. Create a feature branch 3. Implement changes with tests 4. Submit a pull request ## Troubleshooting Common issues and solutions: - **Authentication Errors**: Verify your Hugging Face credentials - **Conversion Failures**: Check model compatibility and available disk space - **Upload Issues**: Ensure stable internet connection and valid permissions ## License [Apache 2.0 License](license.txt)