Concrete_creep_predict / HUGGINGFACE_DEPLOYMENT.md
Sompote's picture
Upload 13 files
dda35dd verified

A newer version of the Streamlit SDK is available: 1.51.0

Upgrade

πŸš€ Hugging Face Spaces Deployment Guide

This guide will help you deploy the Enhanced Concrete Creep Prediction app to Hugging Face Spaces.

πŸ“‹ Prerequisites

  1. Hugging Face Account: Create an account at huggingface.co
  2. Git LFS: Install Git Large File Storage for handling model files
  3. Git: Standard Git installation

πŸ› οΈ Deployment Steps

Step 1: Create a New Space

  1. Go to Hugging Face Spaces
  2. Click "Create new Space"
  3. Configure your space:
    • Name: concrete-creep-prediction (or your preferred name)
    • License: MIT
    • SDK: Streamlit
    • Hardware: CPU Basic (free tier) or CPU Upgrade/GPU for better performance

Step 2: Clone Your New Space

git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME

Step 3: Copy Files from Deploy Directory

Copy all files from the deploy/ directory to your cloned space:

# Copy all files from deploy directory
cp /path/to/your/deploy/* ./

# Ensure executable permissions
chmod +x start_app.sh

Step 4: Initialize Git LFS

git lfs install
git lfs track "*.pt"
git lfs track "*.pkl"

Step 5: Add and Commit Files

git add .
git commit -m "Initial deployment of Enhanced Concrete Creep Prediction app"
git push

πŸ“ Required Files Structure

Your Hugging Face Space should contain:

your-space/
β”œβ”€β”€ app.py                      # Main Streamlit app
β”œβ”€β”€ lllm_model_all_token.py     # Model architecture
β”œβ”€β”€ requirements.txt            # Dependencies
β”œβ”€β”€ README.md                   # Space description (with metadata)
β”œβ”€β”€ .gitattributes             # Git LFS configuration
β”œβ”€β”€ best_llm_model-17.pt       # Primary model (LFS)
β”œβ”€β”€ final_llm_model-5.pt       # Alternative model (LFS)
└── scalers/                   # Scaler files (LFS)
    β”œβ”€β”€ feature_scaler.pkl
    β”œβ”€β”€ creep_scaler.pkl
    └── time_values.pkl

βš™οΈ Configuration Files

requirements.txt

streamlit
pandas
numpy
torch
matplotlib
scikit-learn
pickle-mixin

.gitattributes

*.pt filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text

README.md Header

---
title: Enhanced Concrete Creep Prediction
emoji: πŸ—οΈ
colorFrom: blue
colorTo: green
sdk: streamlit
sdk_version: 1.28.0
app_file: app.py
pinned: false
license: mit
---

🚨 Important Notes

File Size Considerations

  • Model files (~12MB each) require Git LFS
  • Total space size should be under Hugging Face limits
  • Consider using CPU Basic for free deployment

Performance Optimization

  • Remove unused model files if space is limited
  • The app automatically detects available models
  • CPU inference is sufficient for most use cases

Memory Management

  • Hugging Face Spaces have memory limits
  • The app is optimized for cloud deployment
  • Consider reducing default time points if needed

πŸ”§ Troubleshooting

Common Issues:

  1. Git LFS Issues

    git lfs install
    git lfs migrate import --include="*.pt,*.pkl"
    
  2. Build Failures

    • Check requirements.txt format
    • Ensure all files are properly committed
    • Verify Python package compatibility
  3. Memory Errors

    • Upgrade to CPU Upgrade hardware
    • Reduce model complexity in app.py
    • Optimize batch sizes
  4. Model Loading Errors

    • Verify Git LFS is working
    • Check file paths in app.py
    • Ensure proper file permissions

🎯 Optimization Tips

For Better Performance:

  1. Upgrade Hardware: Consider CPU Upgrade or GPU for faster inference
  2. Caching: Streamlit caching is already implemented
  3. Model Selection: Keep only the best performing model file
  4. Time Points: Limit default prediction range for faster response

For Reliability:

  1. Error Handling: Comprehensive error handling is included
  2. Fallbacks: Multiple model loading strategies
  3. User Feedback: Clear status messages and warnings

πŸ“Š Monitoring

After deployment, monitor:

  • Build Logs: Check for any deployment issues
  • Runtime Logs: Monitor app performance
  • User Feedback: Gather usage statistics
  • Resource Usage: Track memory and compute usage

πŸ”„ Updates

To update your deployed app:

# Make changes locally
git add .
git commit -m "Update: [description of changes]"
git push

Hugging Face Spaces will automatically rebuild and redeploy.

πŸ“ž Support


Ready to Deploy! πŸš€

Your Enhanced Concrete Creep Prediction app will be available at: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME