Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

Latest commit

 

History

History
637 lines (485 loc) · 10.9 KB

File metadata and controls

637 lines (485 loc) · 10.9 KB

🤗 HUGGING FACE SPACES DEPLOYMENT

SSZ Interactive3D Viewer - Deployment Guide
Platform: Hugging Face Spaces
Framework: Gradio
Status: Ready to Deploy! 🚀


🎯 QUICK DEPLOYMENT (15 Minutes!)

Step-by-Step Process:

1. Create Account          (2 min)
2. Create Space            (2 min)
3. Upload Files            (5 min)
4. Configure               (3 min)
5. Deploy & Test           (3 min)

Total: ~15 minutes to LIVE! 🌐

📋 STEP 1: CREATE HUGGING FACE ACCOUNT

If you don't have an account:

1. Go to: https://huggingface.co
2. Click "Sign Up"
3. Create account (email or GitHub)
4. Verify email
5. Done!

If you already have an account:

✅ You're ready! Just log in.

🚀 STEP 2: CREATE NEW SPACE

Navigate:

1. Go to: https://huggingface.co/spaces
2. Click: "Create new Space"

Configuration:

Name:           ssz-Interactive3D-viewer
                (or any name you prefer)

License:        ACSL-1.4
                (Anti-Capitalist Software License)

SDK:            Gradio ← WICHTIG!

Hardware:       CPU basic - 2 vCPU, 16 GB RAM (FREE!)
                (Can upgrade later if needed)

Visibility:     Public
                (So anyone can use it!)

Space type:     Gradio

Click: Create Space


📁 STEP 3: UPLOAD FILES

Method A: Web Interface (Easiest!)

3.1: Navigate to Files Tab

In your new Space → Click "Files" tab

3.2: Upload these files ONE BY ONE:

File 1: app.py (Main App)

Click "Add file" → "Create a new file"
Name: app.py
Content: Copy from gradio_app.py

Content to upload:

# Copy ENTIRE content from:
# Interactive3D_ssz_viewer/gradio_app.py
# 
# NOTE: Rename at top if needed:
# from data_manager import DataManager
# becomes:
# from Interactive3D_ssz_viewer.data_manager import DataManager

File 2: requirements.txt

Click "Add file" → "Create a new file"
Name: requirements.txt

Content:

dash>=2.14.0
plotly>=5.17.0
numpy>=1.24.0
pandas>=2.0.0
gradio>=4.0.0
astroquery>=0.4.6
astropy>=6.0.0
psutil>=5.9.0

File 3: README.md (Space Description)

Click "Add file" → "Create a new file"
Name: README.md

Content:

---
title: SSZ Interactive3D Viewer
emoji: 🌌
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.0.0
app_file: app.py
pinned: false
license: other
---

# 🌌 SSZ Interactive3D Viewer

Interactive 3D Visualization of Segmented Spacetime Physics with Real GAIA DR3 Data

## Features

✨ Real GAIA DR3 astronomical data (1.8 billion stars)  
✨ Interactive visualizations  
✨ SSZ vs GR comparison  
✨ Data export capabilities  
✨ Production-ready code  

## Usage

1. **Load GAIA Data**: Choose number of stars and toggle real data
2. **Compare Physics**: Generate SSZ vs GR comparison plots
3. **Explore SSZ**: View pure SSZ physics visualizations
4. **Query Regions**: Search Galactic Center and other regions
5. **View Statistics**: Get dataset information

## About

This tool implements the Segmented Spacetime (SSZ) framework with the golden ratio (φ = 1.618...) as a fundamental constant in spacetime geometry.

**Scientific Background:**
- Segment Density: Ξ(r) = 1 - exp(-φ·r/r_s)
- Time Dilation: D_SSZ = 1/(1 + Ξ)
- No singularities at event horizons

## Repository

GitHub: https://github.com/error-wtf/Segmented-Spacetime-Starmaps

## License

© 2025 Carmen Wrede, Lino Casu  
Licensed under ACSL v1.4 (Anti-Capitalist Software License)

File 4-12: Python Modules

Upload entire Interactive3D_ssz_viewer folder:

Option 1: Upload as ZIP

1. Locally: Zip Interactive3D_ssz_viewer folder
2. HF: Upload → "Upload files"
3. Select ZIP
4. Wait for extraction

Option 2: Upload individually (if ZIP doesn't work)

Create folder: Interactive3D_ssz_viewer/

Upload these files:
  - data_manager.py
  - catalog_fetchers.py
  - comparison_visualizations.py
  - phase1_galaxy_engine.py
  - phase2_system_details.py
  - ssz_data_exporter.py
  - __init__.py (create empty file)

Method B: Git (Advanced)

# Clone your HF Space
git clone https://huggingface.co/spaces/YOUR_USERNAME/ssz-Interactive3D-viewer
cd ssz-Interactive3D-viewer

# Copy files
cp Interactive3D_ssz_viewer/gradio_app.py app.py
cp Interactive3D_ssz_viewer/requirements.txt requirements.txt
cp -r Interactive3D_ssz_viewer/ .

# Commit
git add .
git commit -m "Initial deployment"
git push

⚙️ STEP 4: CONFIGURE

4.1: Update app.py imports (if needed)

If modules in subfolder:

# Change:
from data_manager import DataManager

# To:
from Interactive3D_ssz_viewer.data_manager import DataManager

4.2: Verify requirements.txt

✅ gradio>=4.0.0
✅ All dependencies listed
✅ Version numbers compatible

4.3: Add .gitignore (optional)

__pycache__/
*.pyc
*.pyo
.pytest_cache/
.env

🚀 STEP 5: DEPLOY & WAIT

Automatic Build Process:

1. HF detects changes
2. Builds Docker container
3. Installs dependencies
4. Starts Gradio app
5. Assigns URL

Typical time: 5-10 minutes first time

Monitor Build:

Watch "Logs" tab for:
  - Installing dependencies...
  - Building application...
  - Running on local URL...
  - Running on public URL...
  
✅ When you see public URL → LIVE!

✅ STEP 6: TEST YOUR SPACE

6.1: Access Your Space

URL: https://huggingface.co/spaces/YOUR_USERNAME/ssz-Interactive3D-viewer

Or direct app:
URL: https://YOUR_USERNAME-ssz-Interactive3D-viewer.hf.space

6.2: Test Features

□ Load Data tab works
□ GAIA queries work
□ Plots generate
□ No errors in logs
□ Performance acceptable
□ All tabs functional

6.3: Share!

□ Copy share link
□ Test in incognito/private window
□ Share on social media
□ Add to GitHub README
□ Email to colleagues

🎨 STEP 7: CUSTOMIZE (Optional)

Update Space Settings:

Settings → Edit Space card

Emoji:      🌌 (astronomy)
Color:      blue → purple (gradient)
Tags:       astronomy, physics, gaia, ssz
Featured:   Request featuring (if popular!)

Add Banner Image:

1. Create banner.png (1200x630)
2. Upload to Space
3. Add to README:
   ![Banner](banner.png)

Add Examples:

# In app.py, add examples:
demo.launch(
    share=True,
    examples=[
        [100, True],  # 100 stars, real data
        [1000, False], # 1k stars, synthetic
    ]
)

📊 MONITORING

Check Metrics:

Space page → Insights

Watch:
  - Page views
  - Unique users
  - API calls
  - Errors
  - Performance

Respond to Issues:

Users may:
  - Report bugs
  - Request features
  - Ask questions
  
Be responsive! 😊

⚡ PERFORMANCE TIPS

If Space is Slow:

1. Reduce default data size
   limit=100 instead of 1000
   
2. Optimize imports
   Import only what's needed
   
3. Add caching
   @st.cache_data decorator
   
4. Upgrade hardware
   Settings → Change hardware tier
   (Costs money but faster)

If Space Crashes:

1. Check logs for errors
2. Verify requirements versions
3. Test locally first
4. Reduce memory usage
5. Add error handling

🔄 UPDATING YOUR SPACE

Method 1: Web Interface

1. Edit file directly on HF
2. Commit changes
3. Wait for rebuild
4. Test

Method 2: Git Push

# Update locally
# Then:
git add .
git commit -m "Update: ..."
git push

# HF rebuilds automatically

🎯 SUCCESS CHECKLIST

□ HF account created
□ Space created
□ Files uploaded
  □ app.py
  □ requirements.txt
  □ README.md
  □ Python modules
□ Configuration correct
□ Build successful
□ App accessible
□ All features working
□ No errors in logs
□ Performance acceptable
□ Share link works
□ Added to GitHub README
□ Announced to community

🌟 POST-DEPLOYMENT

Promote Your Space:

1. Add badge to GitHub README:
   [![Open in HF](badge)](url)
   
2. Share on social media:
   "🚀 Just deployed SSZ Interactive3D Viewer on @huggingface! 
   Try it: [URL]"
   
3. Add to HF profile:
   Pin your Space
   
4. Submit to HF collections:
   Astronomy, Physics, Science
   
5. Write blog post:
   Medium, Dev.to, personal blog

Monitor & Improve:

□ Watch usage metrics
□ Respond to feedback
□ Fix bugs quickly
□ Add requested features
□ Update documentation
□ Announce updates

🆘 TROUBLESHOOTING

Build Fails:

Error: "Failed to build"

Solution:
1. Check requirements.txt versions
2. Verify all imports work
3. Test locally first
4. Check logs for specific error
5. Ask in HF Forums if stuck

App Doesn't Start:

Error: "App failed to start"

Solution:
1. Verify app.py has launch()
2. Check all imports resolve
3. Verify file paths
4. Check for syntax errors
5. Review logs carefully

Slow Performance:

Issue: "App is slow"

Solution:
1. Reduce default data size
2. Add caching
3. Optimize queries
4. Upgrade hardware tier
5. Profile code for bottlenecks

Out of Memory:

Error: "OOM (Out of Memory)"

Solution:
1. Reduce data size limits
2. Clear cache more often
3. Optimize data structures
4. Upgrade to larger instance
5. Add memory cleanup

💰 COST CONSIDERATIONS

Free Tier:

✅ CPU basic (2 vCPU, 16 GB RAM)
✅ Unlimited usage
✅ Public Spaces only
✅ Community support

Perfect for most use cases!

Paid Tiers: (if needed)

CPU upgrade:   $0.10/hour (faster)
GPU:          $0.60/hour (for ML)
Private:      $9/month (hide source)

Usually NOT needed for this app!

📈 EXPECTED RESULTS

After Deployment:

✅ Public URL accessible
✅ App loads in ~3-5 seconds
✅ GAIA queries work
✅ Plots generate correctly
✅ No crashes
✅ Shareable link
✅ Discoverable on HF
✅ Usage metrics visible

Typical Usage:

Week 1:    10-50 users
Month 1:   100-500 users
Year 1:    1,000-10,000 users

(With promotion!)

🎊 DEPLOYMENT COMPLETE!

When your Space is live:

✅ Copy share link
✅ Test all features
✅ Add to GitHub README
✅ Announce on social media
✅ Email to colleagues
✅ Celebrate! 🎉

Your app is now:

  • 🌍 Accessible worldwide
  • 🚀 Running 24/7
  • 📊 Tracking metrics
  • 🤝 Open for collaboration
  • ✨ Making an impact!

🔗 USEFUL LINKS

HF Spaces:          https://huggingface.co/spaces
HF Docs:            https://huggingface.co/docs/hub/spaces
Gradio Docs:        https://gradio.app/docs
HF Forums:          https://discuss.huggingface.co
Your Space:         https://huggingface.co/spaces/YOUR_USERNAME/ssz-Interactive3D-viewer

READY TO DEPLOY?

Follow the steps above and your app will be LIVE in ~15 minutes! 🚀

Need help? Let me know! I can guide you through any step! 😊


© 2025 Carmen Wrede, Lino Casu
Licensed under ACSL v1.4