A newer version of the Streamlit SDK is available:
1.41.1
metadata
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
Clone the repository:
git clone https://huggingface.co/spaces/onnx-community/convert-to-onnx cd convert-to-onnx
Install dependencies:
pip install -r requirements.txt
Configure Hugging Face credentials:
# Option 1: Environment variables export HF_TOKEN="your_token" # Option 2: Create .streamlit/secrets.toml echo 'HF_TOKEN = "your_token"' > .streamlit/secrets.toml
Usage
Start the application:
streamlit run app.py
Access the web interface at
http://localhost:8501
Enter a Hugging Face model ID (e.g.,
EleutherAI/pythia-14m
)Click "Proceed" to start the conversion
The converted model will be available in your Hugging Face account as {username}/{model-name}-ONNX
.
Development
Contributing
- Fork the repository
- Create a feature branch
- Implement changes with tests
- 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