AAZ1215 commited on
Commit
38ae4b7
Β·
verified Β·
1 Parent(s): 90c01cf

Delete DEPLOYMENT_README.md

Browse files
Files changed (1) hide show
  1. DEPLOYMENT_README.md +0 -269
DEPLOYMENT_README.md DELETED
@@ -1,269 +0,0 @@
1
- # πŸš€ Group 5 Pattern Recognition Project - Deployment Guide
2
-
3
- ## πŸ“– Overview
4
- This is a recipe recommendation system using semantic search with a trained BERT model. The system provides intelligent recipe recommendations based on semantic understanding of user queries.
5
-
6
- ## 🌐 Live Demo
7
- Deploy this app on **Hugging Face Spaces** for free hosting!
8
-
9
- ## πŸ“ File Setup for Deployment
10
-
11
- ### Step 1: Upload Large Files to Google Drive
12
-
13
- You need to upload these files to Google Drive and make them publicly accessible:
14
-
15
- 1. **torch_recipe_embeddings_231630.pt** (679MB)
16
- 2. **tag_based_bert_model.pth** (418MB)
17
- 3. **RAW_recipes.csv** (281MB)
18
- 4. **recipe_statistics_231630.pkl** (4.3MB)
19
- 5. **recipe_scores_231630.pkl** (3.0MB)
20
-
21
- ### Step 2: Get Google Drive File IDs
22
-
23
- For each file in Google Drive:
24
- 1. Right-click β†’ "Get link"
25
- 2. Make sure it's set to "Anyone with the link can view"
26
- 3. Copy the file ID from the URL: `https://drive.google.com/file/d/FILE_ID_HERE/view`
27
-
28
- ### Step 3: Update File IDs in Code
29
-
30
- Edit `gradio_app_deploy.py` and replace the placeholder IDs:
31
-
32
- ```python
33
- GOOGLE_DRIVE_FILES = {
34
- 'torch_recipe_embeddings_231630.pt': 'YOUR_ACTUAL_EMBEDDINGS_FILE_ID',
35
- 'tag_based_bert_model.pth': 'YOUR_ACTUAL_MODEL_FILE_ID',
36
- 'RAW_recipes.csv': 'YOUR_ACTUAL_RECIPES_FILE_ID',
37
- 'recipe_statistics_231630.pkl': 'YOUR_ACTUAL_STATS_FILE_ID',
38
- 'recipe_scores_231630.pkl': 'YOUR_ACTUAL_SCORES_FILE_ID'
39
- }
40
- ```
41
-
42
- ## πŸ€— Deploy to Hugging Face Spaces
43
-
44
- ### Step 1: Create Hugging Face Account
45
- 1. Go to [huggingface.co](https://huggingface.co)
46
- 2. Sign up for a free account
47
-
48
- ### Step 2: Create New Space
49
- 1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
50
- 2. Click "Create new Space"
51
- 3. Choose:
52
- - **Space name**: `group5-recipe-recommendation`
53
- - **License**: Apache 2.0
54
- - **SDK**: Gradio
55
- - **Hardware**: CPU Basic (free)
56
-
57
- ### Step 3: Upload Files
58
- Upload these files to your Space:
59
-
60
- ```
61
- πŸ“ Your Space Repository
62
- β”œβ”€β”€ app.py (rename gradio_app_deploy.py to app.py)
63
- β”œβ”€β”€ requirements.txt (use requirements_deploy.txt)
64
- └── README.md (this file)
65
- ```
66
-
67
- ### Step 4: Files to Upload
68
-
69
- 1. **Rename** `gradio_app_deploy.py` β†’ `app.py`
70
- 2. **Rename** `requirements_deploy.txt` β†’ `requirements.txt`
71
- 3. **Upload** both files to your Space
72
-
73
- ### Step 5: Configure Space
74
- Your Space will automatically:
75
- 1. Install dependencies from `requirements.txt`
76
- 2. Download files from Google Drive on first run
77
- 3. Start the Gradio app on port 7860
78
-
79
- ## πŸ”§ Alternative Deployment Options
80
-
81
- ### Option 1: Railway
82
- 1. Connect your GitHub repo to [Railway](https://railway.app)
83
- 2. Add environment variables for file URLs
84
- 3. Deploy with automatic builds
85
-
86
- ### Option 2: Render
87
- 1. Connect your GitHub repo to [Render](https://render.com)
88
- 2. Configure build and start commands
89
- 3. Set up environment variables
90
-
91
- ### Option 3: Streamlit Cloud
92
- 1. Convert the app to Streamlit format
93
- 2. Deploy via [streamlit.io](https://streamlit.io)
94
-
95
- ## πŸ“Š Expected Performance
96
- - **Startup Time**: 2-5 minutes (downloading files)
97
- - **Search Speed**: <2 seconds per query
98
- - **Memory Usage**: ~2GB (for full dataset)
99
- - **Storage**: ~1.5GB total
100
-
101
- ## πŸ› Troubleshooting
102
-
103
- ### Common Issues:
104
-
105
- 1. **Files not downloading**
106
- - Check Google Drive file permissions
107
- - Verify file IDs are correct
108
- - Ensure files are public
109
-
110
- 2. **Out of memory**
111
- - Use smaller dataset subset
112
- - Upgrade to paid Hugging Face hardware
113
-
114
- 3. **Slow startup**
115
- - Normal for first run (downloading files)
116
- - Subsequent runs will be faster
117
-
118
- ## πŸ”— Useful Links
119
- - [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)
120
- - [Gradio Documentation](https://gradio.app/docs)
121
- - [PyTorch Documentation](https://pytorch.org/docs)
122
-
123
- ## πŸ”„ GitHub Integration & Auto-Sync
124
-
125
- ### Option 1: Direct GitHub Connection (Recommended)
126
-
127
- 1. **In your Hugging Face Space settings**:
128
- - Go to your Space β†’ Settings β†’ Repository
129
- - Click "Connect to GitHub"
130
- - Authorize Hugging Face to access your GitHub repo
131
- - Select your repository: `PatternRec_Project_Group7`
132
-
133
- 2. **Configure auto-sync**:
134
- - Enable "Auto-sync with GitHub"
135
- - Choose branch (usually `main`)
136
- - Set sync frequency (immediate, hourly, daily)
137
-
138
- 3. **Result**: Every time you push to GitHub, your Hugging Face Space will automatically update!
139
-
140
- ### Option 2: GitHub Actions (Advanced)
141
-
142
- Create `.github/workflows/deploy-to-hf.yml` in your repo:
143
-
144
- ```yaml
145
- name: Deploy to Hugging Face Spaces
146
-
147
- on:
148
- push:
149
- branches: [ main ]
150
- pull_request:
151
- branches: [ main ]
152
-
153
- jobs:
154
- deploy:
155
- runs-on: ubuntu-latest
156
- steps:
157
- - uses: actions/checkout@v3
158
-
159
- - name: Push to Hugging Face Spaces
160
- env:
161
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
162
- run: |
163
- git config --global user.email "action@github.com"
164
- git config --global user.name "GitHub Action"
165
-
166
- # Clone your HF Space repo
167
- git clone https://huggingface.co/spaces/YOUR_USERNAME/group5-recipe-recommendation hf-space
168
- cd hf-space
169
-
170
- # Copy files from GitHub repo
171
- cp ../gradio_app_deploy.py ./app.py
172
- cp ../requirements_deploy.txt ./requirements.txt
173
- cp ../DEPLOYMENT_README.md ./README.md
174
-
175
- # Push to HF Space
176
- git add .
177
- git commit -m "Auto-sync from GitHub: ${{ github.event.head_commit.message }}"
178
- git push https://USER:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/YOUR_USERNAME/group5-recipe-recommendation
179
- ```
180
-
181
- ### Option 3: Dual Git Remotes
182
-
183
- Set up your local repo to push to both GitHub and Hugging Face:
184
-
185
- ```bash
186
- # Add HF Space as second remote
187
- git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/group5-recipe-recommendation
188
-
189
- # Push to both with one command
190
- git push origin main # GitHub
191
- git push hf main # Hugging Face Space
192
-
193
- # Or create an alias for both
194
- git config alias.pushall '!git push origin main && git push hf main'
195
- # Then use: git pushall
196
- ```
197
-
198
- ### Option 4: Automated Script
199
-
200
- Create a deployment script `deploy.sh`:
201
-
202
- ```bash
203
- #!/bin/bash
204
- echo "πŸš€ Deploying to Hugging Face Space..."
205
-
206
- # Copy deployment files
207
- cp gradio_app_deploy.py app.py
208
- cp requirements_deploy.txt requirements.txt
209
-
210
- # Commit changes
211
- git add app.py requirements.txt README.md
212
- git commit -m "Deploy: $(date)"
213
-
214
- # Push to GitHub
215
- git push origin main
216
-
217
- # Push to Hugging Face Space
218
- git push hf main
219
-
220
- echo "βœ… Deployment complete!"
221
- ```
222
-
223
- ### Recommended Workflow
224
-
225
- 1. **Set up direct GitHub connection** (easiest)
226
- 2. **Structure your repo** with deployment-ready files:
227
- ```
228
- πŸ“ Your GitHub Repo
229
- β”œβ”€β”€ gradio_app_deploy.py # Main app (will become app.py)
230
- β”œβ”€β”€ requirements_deploy.txt # Dependencies (will become requirements.txt)
231
- β”œβ”€β”€ DEPLOYMENT_README.md # This file (will become README.md)
232
- β”œβ”€β”€ gradio_app_fixed.py # Development version
233
- └── ... other project files
234
- ```
235
-
236
- 3. **Configure auto-sync** in HF Space settings
237
- 4. **Push to GitHub** - HF Space updates automatically!
238
-
239
- ### File Mapping for Auto-Sync
240
-
241
- When files sync from GitHub β†’ Hugging Face Space:
242
-
243
- | GitHub File | β†’ | HF Space File | Purpose |
244
- |-------------|---|---------------|---------|
245
- | `gradio_app_deploy.py` | β†’ | `app.py` | Main application |
246
- | `requirements_deploy.txt` | β†’ | `requirements.txt` | Dependencies |
247
- | `DEPLOYMENT_README.md` | β†’ | `README.md` | Documentation |
248
-
249
- ### Benefits of GitHub Integration
250
-
251
- βœ… **Version Control**: Keep your code in GitHub
252
- βœ… **Automatic Updates**: Push once, deploy everywhere
253
- βœ… **Collaboration**: Team members can contribute via GitHub
254
- βœ… **Backup**: Multiple copies of your code
255
- βœ… **CI/CD**: Run tests before deployment
256
-
257
- ## πŸ†˜ Support
258
- If you encounter issues:
259
- 1. Check the Space logs in Hugging Face
260
- 2. Verify all file IDs are correct
261
- 3. Ensure requirements.txt has all dependencies
262
-
263
- ## 🎯 Success Criteria
264
- βœ… App loads without errors
265
- βœ… Search functionality works
266
- βœ… Results show relevant recipes
267
- βœ… Interface is responsive
268
-
269
- Your app should be accessible at: `https://huggingface.co/spaces/YOUR_USERNAME/group5-recipe-recommendation`