File size: 2,194 Bytes
d088d6c
 
 
 
 
 
f2501ef
d088d6c
9bfcf12
d088d6c
f2501ef
d088d6c
f2501ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
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)