Spaces:
Build error
Build error
A newer version of the Streamlit SDK is available: 1.56.0
π Deployment Guide for Hugging Face Spaces
This guide will help you deploy the Crystallization Component Predictor to Hugging Face Spaces.
π Prerequisites
- A Hugging Face account (sign up at https://huggingface.co/)
- Git installed on your computer
- Git LFS installed (
git lfs install)
π§ Step-by-Step Deployment
Option 1: Web UI Upload (Easiest)
Create a new Space:
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Choose a name (e.g., "crystallization-predictor")
- Select Streamlit as the SDK
- Choose visibility (Public or Private)
- Click "Create Space"
Upload files:
- Click "Files" tab in your Space
- Click "Add file" β "Upload files"
- Drag and drop ALL files from this
huggingface_appfolder:app.pyrequirements.txtREADME.md.gitattributes.gitignoremodels/folder (with all subfolders)visualizations/folder (with all images)
- Click "Commit changes to main"
Wait for build:
- Hugging Face will automatically build your Space
- Check the "Logs" tab to monitor progress
- Usually takes 2-5 minutes
Test your app:
- Once built, click on the "App" tab
- Your Streamlit app should be running!
Option 2: Git Command Line (Advanced)
- Initialize Git LFS:
cd huggingface_app
git lfs install
- Clone your Space repository:
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
- Copy files:
# Copy all files from huggingface_app to your cloned repo
# On Windows:
xcopy ..\huggingface_app\* . /E /H /Y
# On Linux/Mac:
cp -r ../huggingface_app/* .
- Commit and push:
git add .
git commit -m "Initial deployment of crystallization predictor"
git push
- Check deployment:
- Visit your Space URL:
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME - Monitor build logs in the "Logs" tab
- Visit your Space URL:
π Files Included
huggingface_app/
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ README.md # Documentation (shown on Space page)
βββ .gitattributes # Git LFS configuration
βββ .gitignore # Files to ignore
βββ DEPLOYMENT_GUIDE.md # This file
βββ models/
β βββ simple_baseline/
β β βββ model_component_name.pkl
β β βββ model_component_ph.pkl
β β βββ label_encoder_name.pkl
β β βββ scaler.pkl
β β βββ tfidf.pkl
β β βββ training_results.json
β βββ advanced_baseline/
β βββ model_component_name.pkl
β βββ model_component_conc.pkl
β βββ model_component_ph.pkl
β βββ label_encoder_name.pkl
β βββ scaler.pkl
β βββ tfidf.pkl
β βββ training_results.json
βββ visualizations/
βββ 01_component_name_comparison.png
βββ 02_component_conc_comparison.png
βββ 03_component_ph_comparison.png
βββ 04_all_approaches_heatmap.png
βββ 05_complete_comparison.png
π Troubleshooting
Build Fails
Problem: "Could not install packages due to an OSError"
- Solution: Check that all dependencies in
requirements.txtare compatible - Try pinning versions or using newer versions
Problem: "ModuleNotFoundError"
- Solution: Ensure the missing module is in
requirements.txt
Model Loading Errors
Problem: "FileNotFoundError: [Errno 2] No such file or directory: 'models/...'"
- Solution: Verify all model files were uploaded correctly
- Check that folder structure is preserved
Problem: Large file upload fails
- Solution: Ensure Git LFS is properly configured
- Files over 10MB should use LFS (already configured in
.gitattributes)
App Crashes
Problem: "Memory limit exceeded"
- Solution: Hugging Face Spaces have memory limits
- Consider using smaller models or optimizing loading
Problem: Slow loading
- Solution: Models are loaded on first prediction (not at startup)
- This is intentional for faster app startup
π¨ Customization
Change App Title/Icon
Edit the README.md header:
```yaml
title: Your Custom Title emoji: 𧬠# Change emoji colorFrom: blue # Change colors colorTo: purple
### Modify the App
Edit `app.py` and commit changes. The Space will rebuild automatically.
### Add More Models
1. Add model files to `models/` folder
2. Update `app.py` to load and use new models
3. Update `README.md` to document changes
## π Monitoring
- **Logs**: Check the "Logs" tab in your Space
- **Analytics**: View usage statistics in Space settings
- **Updates**: Any push to the main branch triggers a rebuild
## π Security & Privacy
- **Public Spaces**: Anyone can use your app and see the code
- **Private Spaces**: Only you and collaborators can access
- **No User Data**: The app doesn't collect or store user inputs
- **Model Files**: Ensure you have rights to distribute the models
## π° Costs
- **Free Tier**:
- CPU: 2 vCPU, 16GB RAM
- Perfect for this app
- No credit card required
- **Paid Tiers**:
- Available for GPU or more resources
- Not needed for this application
## π Useful Links
- Hugging Face Spaces Docs: https://huggingface.co/docs/hub/spaces
- Streamlit Docs: https://docs.streamlit.io/
- Git LFS: https://git-lfs.github.com/
## π Support
If you encounter issues:
1. Check the "Logs" tab in your Space
2. Review Hugging Face Spaces documentation
3. Search Hugging Face forums
4. Open an issue on the repository
## β
Pre-Deployment Checklist
- [ ] All model files copied to `models/` folders
- [ ] Visualizations copied to `visualizations/` folder
- [ ] `requirements.txt` has all dependencies
- [ ] `README.md` header configured with title/emoji
- [ ] Tested app locally (`streamlit run app.py`)
- [ ] Git LFS installed and configured
- [ ] Hugging Face account created
- [ ] Space created on Hugging Face
## π Post-Deployment
After successful deployment:
1. Test all features in the live app
2. Share your Space URL with others
3. Monitor logs for any errors
4. Consider adding:
- Example inputs/outputs
- Tutorial video
- Publication link
- Citation information
---
**Good luck with your deployment! π**
Your app will be accessible at:
`https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME`