Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
5.49.1
HuggingFace Space Deployment Guide
This directory contains files for deploying the DGA classifier to HuggingFace Spaces.
Files
app.py- Main Gradio applicationrequirements.txt- Python dependenciesREADME.md- Space description and metadata
Deployment Steps
1. Upload Model to HuggingFace Hub
First, upload your trained model:
# Make sure you have huggingface_hub installed
pixi add huggingface_hub
# Login to HuggingFace (get token from https://huggingface.co/settings/tokens)
pixi run huggingface-cli login
# Upload the model
cd .. # Go back to project root
pixi run python upload_to_hf.py
2. Create HuggingFace Space
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Fill in the details:
- Space name:
dga-detector(or any name you prefer) - License: MIT
- SDK: Gradio
- Hardware: CPU Basic (free) or GPU if you need faster inference
- Visibility: Public
- Space name:
3. Upload Files to Space
You can either:
Option A: Use Git (Recommended)
# Clone your Space repository
git clone https://huggingface.co/spaces/ccss17/dga-detector
cd dga-detector
# Copy files from this directory
cp ../hf_space/* .
# Update app.py with your model name
# Edit line 34: MODEL_NAME = "YOUR_USERNAME/dga-transformer-encoder"
# Commit and push
git add .
git commit -m "Initial commit: DGA detector demo"
git push
Option B: Use Web UI
- Go to your Space page
- Click "Files" tab
- Upload
app.py,requirements.txt, andREADME.md
4. Update Model Name
In app.py, line 34, change:
MODEL_NAME = "ccss17/dga-transformer-encoder"
to:
MODEL_NAME = "YOUR_USERNAME/dga-transformer-encoder"
5. Wait for Build
HuggingFace will automatically:
- Install dependencies from
requirements.txt - Download your model from HuggingFace Hub
- Build and deploy the Gradio app
This usually takes 2-5 minutes.
6. Test Your Space
Once deployed, your Space will be available at:
https://huggingface.co/spaces/YOUR_USERNAME/dga-detector
Troubleshooting
Model not found
- Make sure you uploaded the model to HuggingFace Hub first
- Check that the model name in
app.pymatches your repository
Build fails
- Check the "Logs" tab in your Space
- Ensure
requirements.txthas all necessary dependencies - Make sure you're using compatible versions
Slow inference
- Consider upgrading to GPU hardware (Settings > Hardware)
- Free GPU is available: T4 small
Customization
Change theme
In app.py, line 179:
with gr.Blocks(title="DGA Domain Classifier", theme=gr.themes.Soft()) as demo:
Try other themes: gr.themes.Base(), gr.themes.Default(), gr.themes.Glass()
Add more examples
Edit the EXAMPLES list in app.py (line 160)
Modify UI
Edit the Gradio Blocks structure in app.py (lines 179-340)