niru-nny commited on
Commit
2cac6d4
Β·
verified Β·
1 Parent(s): 0a5d9c1

Upload DEPLOYMENT_GUIDE.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. DEPLOYMENT_GUIDE.md +230 -0
DEPLOYMENT_GUIDE.md ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸš€ Deployment Guide: Hugging Face Model Hub
2
+
3
+ This guide walks you through deploying your California House Price Prediction model to the Hugging Face Model Hub (not Spaces).
4
+
5
+ ## πŸ“‹ Prerequisites
6
+
7
+ βœ… **Already completed:**
8
+
9
+ - [x] Trained model saved as `house_price_model.joblib`
10
+ - [x] Preprocessing pipeline saved as `preprocessing_pipeline.joblib`
11
+ - [x] Python inference API (`inference.py`)
12
+ - [x] Comprehensive README.md (model card)
13
+ - [x] requirements.txt with dependencies
14
+ - [x] LICENSE file (MIT)
15
+ - [x] .gitattributes for Git LFS
16
+ - [x] Example usage script
17
+
18
+ **You need:**
19
+
20
+ - [ ] Hugging Face account ([Sign up here](https://huggingface.co/join))
21
+ - [ ] Git installed on your system
22
+ - [ ] Git LFS installed ([Download here](https://git-lfs.github.com/))
23
+ - [ ] Hugging Face CLI installed
24
+
25
+ ## πŸ”§ Step 1: Install Hugging Face CLI
26
+
27
+ Open PowerShell and run:
28
+
29
+ ```powershell
30
+ pip install huggingface_hub
31
+ ```
32
+
33
+ ## πŸ”‘ Step 2: Login to Hugging Face
34
+
35
+ ```powershell
36
+ huggingface-cli login
37
+ ```
38
+
39
+ You'll be prompted to enter your Hugging Face token. Get your token from:
40
+ <https://huggingface.co/settings/tokens>
41
+
42
+ ## πŸ“¦ Step 3: Initialize Git LFS
43
+
44
+ Make sure Git LFS is installed and initialized:
45
+
46
+ ```powershell
47
+ # Install Git LFS (if not already installed)
48
+ # Download from: https://git-lfs.github.com/
49
+
50
+ # Initialize Git LFS
51
+ git lfs install
52
+ ```
53
+
54
+ ## 🎯 Step 4: Create Model Repository on Hugging Face
55
+
56
+ ### Option A: Using the Web Interface
57
+
58
+ 1. Go to <https://huggingface.co/new>
59
+ 2. Choose a repository name (e.g., `house-price-prediction`)
60
+ 3. Set to **Public** or **Private**
61
+ 4. Click "Create Model"
62
+
63
+ ### Option B: Using CLI
64
+
65
+ ```powershell
66
+ huggingface-cli repo create house-price-prediction --type model
67
+ ```
68
+
69
+ ## πŸ“€ Step 5: Push Your Model
70
+
71
+ Navigate to your project directory and run:
72
+
73
+ ```powershell
74
+ cd "d:\My House Price Project"
75
+
76
+ # Initialize git (if not already initialized)
77
+ git init
78
+
79
+ # Add Git LFS tracking for model files
80
+ git lfs install
81
+ git lfs track "*.joblib"
82
+
83
+ # Add all files
84
+ git add .
85
+
86
+ # Commit
87
+ git commit -m "Initial commit: California House Price Prediction Model"
88
+
89
+ # Add remote (replace YOUR_USERNAME with your Hugging Face username)
90
+ git remote add origin https://huggingface.co/YOUR_USERNAME/house-price-prediction
91
+
92
+ # Push to Hugging Face
93
+ git push -u origin main
94
+ ```
95
+
96
+ ### If you encounter authentication issues
97
+
98
+ Use your Hugging Face username and your **access token** as password when prompted.
99
+
100
+ ## 🏷️ Step 6: Add Model Tags (Optional but Recommended)
101
+
102
+ Edit your model card on Hugging Face web interface or add to the top of README.md:
103
+
104
+ ```yaml
105
+ ---
106
+ tags:
107
+ - tabular
108
+ - regression
109
+ - scikit-learn
110
+ - house-prices
111
+ - california
112
+ - random-forest
113
+ - real-estate
114
+ license: mit
115
+ datasets:
116
+ - california-housing
117
+ metrics:
118
+ - rmse
119
+ library_name: sklearn
120
+ ---
121
+ ```
122
+
123
+ ## βœ… Step 7: Verify Deployment
124
+
125
+ 1. Visit `https://huggingface.co/YOUR_USERNAME/house-price-prediction`
126
+ 2. Check that all files are visible:
127
+ - README.md displays as model card
128
+ - Model files (*.joblib) show LFS badge
129
+ - inference.py and other files are accessible
130
+
131
+ ## πŸ“₯ Step 8: Test Loading from Hub (Optional)
132
+
133
+ Users can now clone and use your model:
134
+
135
+ ```python
136
+ from huggingface_hub import hf_hub_download
137
+ import joblib
138
+
139
+ # Download model files
140
+ model_path = hf_hub_download(
141
+ repo_id="YOUR_USERNAME/house-price-prediction",
142
+ filename="house_price_model.joblib"
143
+ )
144
+ pipeline_path = hf_hub_download(
145
+ repo_id="YOUR_USERNAME/house-price-prediction",
146
+ filename="preprocessing_pipeline.joblib"
147
+ )
148
+
149
+ # Load model
150
+ model = joblib.load(model_path)
151
+ pipeline = joblib.load(pipeline_path)
152
+
153
+ print("βœ… Model loaded from Hugging Face Hub!")
154
+ ```
155
+
156
+ Or simply clone the entire repo:
157
+
158
+ ```bash
159
+ git clone https://huggingface.co/YOUR_USERNAME/house-price-prediction
160
+ cd house-price-prediction
161
+ python inference.py
162
+ ```
163
+
164
+ ## πŸ”„ Step 9: Update Your Model (Future Updates)
165
+
166
+ When you make changes:
167
+
168
+ ```powershell
169
+ cd "d:\My House Price Project"
170
+
171
+ # Make your changes, then:
172
+ git add .
173
+ git commit -m "Description of changes"
174
+ git push
175
+ ```
176
+
177
+ ## 🌟 Step 10: Make Your Model Discoverable
178
+
179
+ 1. **Add a good description** on the Hugging Face web interface
180
+ 2. **Add relevant tags**: tabular, regression, scikit-learn, etc.
181
+ 3. **Fill in the model card** with detailed information
182
+ 4. **Add examples** in the README
183
+ 5. **Share on social media** or the Hugging Face forums
184
+
185
+ ## πŸ“Š Difference: Model Hub vs Spaces
186
+
187
+ You're deploying to **Model Hub** (not Spaces):
188
+
189
+ | Feature | Model Hub | Spaces |
190
+ |---------|-----------|--------|
191
+ | Purpose | Host model files + docs | Host interactive demos |
192
+ | Files | Model artifacts (.joblib, .pkl, etc.) | App code (app.py, requirements.txt) |
193
+ | Interface | Repository with model card | Live web application (Gradio/Streamlit) |
194
+ | Usage | Download and use programmatically | Interactive web UI |
195
+ | What you did | βœ… This guide | ❌ Different (would need app.py) |
196
+
197
+ ## πŸ†˜ Troubleshooting
198
+
199
+ ### Large file errors?
200
+
201
+ Make sure Git LFS is properly configured:
202
+
203
+ ```powershell
204
+ git lfs track "*.joblib"
205
+ git add .gitattributes
206
+ git commit -m "Add LFS tracking"
207
+ ```
208
+
209
+ ### Authentication failed?
210
+
211
+ Use your Hugging Face access token (not password) when pushing.
212
+
213
+ ### Model not showing up?
214
+
215
+ Wait a few minutes, then refresh. Check your repository on huggingface.co.
216
+
217
+ ## πŸŽ‰ Success
218
+
219
+ Your model is now on Hugging Face Model Hub!
220
+
221
+ Next steps:
222
+
223
+ - Share your model with the community
224
+ - Add more examples and documentation
225
+ - Consider creating a Gradio Space for an interactive demo (separate from this)
226
+ - Collect feedback and iterate
227
+
228
+ ---
229
+
230
+ **Need help?** Visit the [Hugging Face forums](https://discuss.huggingface.co/)