Spaces:
Sleeping
Sleeping
File size: 1,885 Bytes
25a1f05 |
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 |
#!/bin/bash
# Script to deploy the application to Hugging Face Spaces
set -e
# Check if huggingface_hub is installed
if ! pip show huggingface_hub > /dev/null 2>&1; then
echo "Installing huggingface_hub..."
pip install huggingface_hub
fi
# Check if git is installed
if ! command -v git &> /dev/null; then
echo "Error: git is not installed. Please install git and try again."
exit 1
fi
# Get Hugging Face username
read -p "Enter your Hugging Face username: " HF_USERNAME
if [ -z "$HF_USERNAME" ]; then
echo "Error: Hugging Face username cannot be empty."
exit 1
fi
# Get Space name
read -p "Enter a name for your Hugging Face Space (lowercase, no spaces): " SPACE_NAME
if [ -z "$SPACE_NAME" ]; then
echo "Error: Space name cannot be empty."
exit 1
fi
# Convert to lowercase and replace spaces with dashes
SPACE_NAME=$(echo "$SPACE_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
# Create examples directory
mkdir -p examples
# Download example images
python download_examples.py
# Initialize git repository if not already initialized
if [ ! -d .git ]; then
git init
fi
# Create Hugging Face Space using the API
echo "Creating Hugging Face Space..."
python -c "from huggingface_hub import create_repo; create_repo(repo_id='$HF_USERNAME/$SPACE_NAME', repo_type='space', space_sdk='gradio')"
# Add remote
git remote add origin https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME || git remote set-url origin https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME
# Add all files
git add .
# Commit
git commit -m "Initial commit with proper configuration"
# Push to Hugging Face
echo "Pushing to Hugging Face Spaces..."
git push -u origin main --force
echo "Deployment complete! Your application is now available at: https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME"
echo "Note: It may take a few minutes for the application to build and deploy." |