Spaces:
Runtime error
A newer version of the Streamlit SDK is available: 1.62.0
π Getting Started with the Edge Detection Demo
Prerequisites
- Python 3.11+ (Python 3.9+ should also work)
- Git (for cloning the repository)
- pip (usually comes with Python)
- 5-10 minutes of your time
Optional:
- Make (for convenient commands)
- Docker (for containerized deployment)
β‘οΈ Quick Start (30 seconds)
The absolute fastest way to get started:
# 1. Navigate to the project directory
cd edge-detection
# 2. Run the setup script
./setup.sh
# 3. Run the app
./run_simple.sh
That's it! Your browser should open to http://localhost:8501
π Detailed Installation
Step 1: Clone the Repository (if needed)
git clone <repository-url>
cd edge-detection
Step 2: Choose Your Setup Method
Option A: Automated Setup Script (Recommended)
chmod +x setup.sh
./setup.sh
This will:
- Check Python version
- Create a virtual environment
- Install all dependencies
Option B: Manual Setup
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On macOS/Linux
# OR
venv\Scripts\activate # On Windows
# Upgrade pip
pip install --upgrade pip
# Install dependencies
pip install -r requirements.txt
Option C: Using Make
make setup
Step 3: Run the Application
Option A: Quick Run Script
chmod +x run_simple.sh
./run_simple.sh
Option B: Manual Run
source venv/bin/activate # Activate virtual environment
streamlit run app.py
Option C: Using Make
make run
Step 4: Open in Browser
The app should automatically open in your default browser at:
http://localhost:8501
If it doesn't open automatically, manually navigate to that URL.
π First Steps in the Demo
Once the app is running:
Upload an Image (optional)
- Look in the sidebar
- Click "Upload your own image"
- Or use the default generated image
Try Different Methods
- Select "Sobel" from the dropdown
- Observe the edge detection results
- Try adjusting the kernel size
- Enable "Show Gradient Components"
Explore Prewitt and Roberts
- Switch methods and compare results
- Notice differences in edge quality and noise sensitivity
Experiment with Laplacian
- Observe the isotropic response
- See why pre-smoothing is important
- Try different kernel sizes
Master Canny
- Adjust low and high thresholds
- Observe edge connectivity
- Compare with simpler methods using comparison mode
Read Educational Content
- Click on the four tabs at the bottom
- Read the explanations
- Understand the mathematical foundations
π§ Troubleshooting
Problem: "Python not found"
Solution:
# Check if Python is installed
python3 --version
# If not, install Python 3.11+ from python.org
Problem: "Permission denied" when running scripts
Solution:
chmod +x *.sh
Problem: Import errors when running
Solution:
# Make sure you're in the virtual environment
source venv/bin/activate
# Reinstall requirements
pip install --force-reinstall -r requirements.txt
Problem: "Port 8501 already in use"
Solution:
# Find and kill the process using the port
lsof -ti:8501 | xargs kill
# Or run on a different port
streamlit run app.py --server.port 8502
Problem: Images not displaying
Solution:
- Check internet connection (for HuggingFace download)
- The app will automatically fall back to a generated image
- Try uploading your own image via the sidebar
Problem: Slow performance
Solution:
- Use smaller images (app auto-resizes to 512px)
- Close other applications
- Try simpler methods (Roberts, Sobel) instead of Canny
π― Next Steps
For Students
- Work through the educational tabs systematically
- Try uploading different types of images (portraits, landscapes, text)
- Compare all five methods on the same image
- Answer the discussion questions in PROJECT_SUMMARY.md
For Instructors
- Review QUICKSTART.md for teaching tips
- Customize the app (see CONTRIBUTING.md)
- Deploy to Hugging Face Spaces (see below)
- Share with your class
For Developers
- Read CONTRIBUTING.md for development guidelines
- Check out PROJECT_SUMMARY.md for technical details
- Consider adding new features (multi-scale, learning-based methods)
π Deploying to Hugging Face Spaces
Want to share this with others online?
Step 1: Create a Hugging Face Account
- Go to https://huggingface.co/join
- Sign up for free
Step 2: Create a New Space
- Go to https://huggingface.co/new-space
- Choose "Streamlit" as the SDK
- Make it public (for educational use)
Step 3: Deploy
chmod +x deploy.sh
./deploy.sh
Follow the prompts and enter your Space name (e.g., "username/edge-detection-demo").
Your demo will be live at: https://huggingface.co/spaces/username/edge-detection-demo
π³ Docker Deployment (Advanced)
If you prefer Docker:
# Build the image
docker build -t edge-detection .
# Run the container
docker run -p 8501:8501 edge-detection
# Access at http://localhost:8501
π Common Commands Reference
# Setup and installation
./setup.sh # Initial setup
make setup # Alternative using make
# Running the app
./run_simple.sh # Quick run
make run # Alternative using make
streamlit run app.py # Direct run
# Testing
python test_setup.py # Verify installation
make test # Alternative using make
# Deployment
./deploy.sh # Deploy to HuggingFace
make deploy # Alternative using make
# Cleanup
make clean # Remove virtual environment
π‘ Tips for Best Experience
- Image Selection: Use images with clear edges (buildings, objects, text)
- Pre-processing: Enable Gaussian blur for noisy images
- Parameter Tuning: Start with default values, then experiment
- Comparison: Use comparison mode to understand differences
- Educational Content: Read tabs in order (What Are Edges? β Gradient Methods β Canny β Practical)
π Learning Path
Beginner (1-2 hours):
- Read "What Are Edges?" tab
- Try Roberts and Sobel
- Compare results on sample image
- Upload your own image
Intermediate (2-4 hours):
- Study gradient-based methods tab
- Experiment with all five methods
- Enable gradient visualizations
- Try different kernel sizes
- Read Canny algorithm tab
Advanced (4+ hours):
- Study practical considerations tab
- Tune Canny parameters systematically
- Compare methods quantitatively
- Test on domain-specific images
- Consider implementing improvements
π Getting Help
- Documentation: Check README.md, QUICKSTART.md, PROJECT_SUMMARY.md
- GitHub Issues: Report bugs or request features
- Discussion Board: Ask questions about edge detection concepts
β Verification
To verify everything is working correctly:
python test_setup.py
This will check:
- All dependencies are installed
- App structure is correct
- Edge detection functions work
- Visualizations render properly
Ready to explore edge detection? Run ./run_simple.sh and start learning! π