Spaces:
Sleeping
Sleeping
File size: 2,455 Bytes
0f43e0e | 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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # π Deployment Guide - Using HuggingFace Models
## β
Perfect Setup!
You've uploaded your models to HuggingFace at: **`anis80/anisproject`**
The app is now configured to download models from there automatically!
---
## π€ Deploy to Render (Recommended - Free)
### Step 1: Push to GitHub
```powershell
cd e:\anis
# Add GitHub remote (replace YOUR_USERNAME)
git remote add origin https://github.com/YOUR_USERNAME/sentiment-analysis-backend.git
git branch -M main
# Push to GitHub
git push -u origin main
```
### Step 2: Deploy to Render
1. Go to: **https://render.com**
2. Sign up with GitHub
3. Create **"New Web Service"**
4. Connect your `sentiment-analysis-backend` repository
5. Configure:
- **Name**: `sentiment-analysis-api`
- **Runtime**: `Python 3`
- **Build Command**: `pip install -r requirements.txt`
- **Start Command**: `uvicorn app:app --host 0.0.0.0 --port $PORT`
- **Instance Type**: **Free**
6. Click **"Create Web Service"**
### Step 3: Wait for Deployment (3-5 minutes)
Your API will be live at: `https://sentiment-analysis-api-XXXX.onrender.com`
---
## π Alternative: Deploy to HuggingFace Spaces
Since your models are already on HuggingFace, you can also deploy there:
### Create Space
1. Go to: https://huggingface.co/new-space
2. Name: `sentiment-analysis-api`
3. SDK: **Docker**
4. Hardware: **CPU basic (Free)**
### Push Code
```powershell
cd e:\anis
# Add HuggingFace remote
git remote add hf https://huggingface.co/spaces/anis80/sentiment-analysis-api
git push hf main
```
---
## β
Benefits of This Approach
- β
**No large files in repository** (only ~10KB of code)
- β
**Models downloaded on startup** from HuggingFace
- β
**Works on any platform** (Render, HuggingFace, Railway, etc.)
- β
**Easy model updates** - just update on HuggingFace
- β
**Free deployment** on both platforms
---
## π§ͺ Test Locally First
```powershell
cd e:\anis
pip install -r requirements.txt
python app.py
```
Visit: http://localhost:7860/docs
---
## π Update Frontend
Once deployed, update `index.html` lines 72-73:
```javascript
const predictApi = 'https://YOUR_DEPLOYMENT_URL/predict';
const statusApi = 'https://YOUR_DEPLOYMENT_URL/status';
```
Then deploy frontend to Vercel!
---
## π° Cost: $0/month π
Both Render and HuggingFace offer free tiers perfect for this project!
---
**Ready to deploy?** Choose Render or HuggingFace and follow the steps above! π
|