Streamlit Deployment Guide
Deploy to Streamlit Community Cloud
Follow the same pattern as the NLP project:
1. Push to GitHub
Make sure your code is in a GitHub repository:
cd "/Users/tay/Development/portfolio projects/cv200"
# If not already a git repo, initialize and push to GitHub
git remote add origin https://github.com/your-username/cv200.git
git push -u origin main
2. Deploy on Streamlit Cloud
Go to Streamlit Community Cloud:
- Visit https://share.streamlit.io/
- Sign in with GitHub
- Click "New app"
Configure deployment:
- Repository: Select your GitHub repo (the one with
streamlit_app.py) - Branch:
main(or your branch) - Main file path:
streamlit_app.py - Python version: 3.9 or 3.10
- Repository: Select your GitHub repo (the one with
Set Secrets (optional but recommended):
- Click "Advanced settings"
- Add secret:
API_URL=https://solarevat-cv200.hf.space - This allows the app to use your HF Spaces API
Deploy:
- Click "Deploy"
- Streamlit will automatically:
- Install dependencies from
requirements-streamlit.txt - Run
streamlit run streamlit_app.py
- Install dependencies from
- Your app will be live at:
https://your-app-name.streamlit.app
3. Verify Deployment
- Open your Streamlit app URL
- Upload a pet image
- Verify it calls your HF Spaces API correctly
Local Testing
Before deploying, test locally:
cd "/Users/tay/Development/portfolio projects/cv200"
pip install -r requirements-streamlit.txt
streamlit run streamlit_app.py
Then open http://localhost:8501 in your browser.
Update API URL
If your API URL is different, edit streamlit_app.py:
API_URL = "https://your-actual-url.hf.space"
Features
- β Image upload with preview
- β Top 5 predictions with confidence scores
- β Progress bars for visual feedback
- β Sidebar with API information
- β Error handling
- β Responsive design
Notes
- The Streamlit app calls your HF Spaces API
- Make sure CORS is enabled in your API (already done)
- The app doesn't need the model files - it just calls the API
- Much simpler than managing HTML/JavaScript!