| Component | Minimum | Recommended |
|---|---|---|
| RAM | 512 MB | 2 GB |
| Disk Space | 500 MB | 2 GB |
| CPU | 1 Core | 2+ Cores |
| OS | Linux, macOS, Windows | Linux (Production) |
git clone https://github.com/Gtajisan/NAFNet-Image-Restoration-API.git
cd NAFNet-Image-Restoration-API
# Linux/macOS
python3 -m venv venv
source venv/bin/activate
# Windows
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python app.py
Open browser: http://localhost:5000
git clone https://github.com/Gtajisan/NAFNet-Image-Restoration-API.git
cd NAFNet-Image-Restoration-API
python3 --version # Should be 3.8 or higher
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
python app.py
In another terminal:
curl http://localhost:5000/api/info
git clone https://github.com/Gtajisan/NAFNet-Image-Restoration-API.git
cd NAFNet-Image-Restoration-API
python --version # Should be 3.8 or higher
python -m venv venv
venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
python app.py
Open browser: http://localhost:5000
docker build -t nafnet-api:latest .
docker run -p 5000:5000 nafnet-api:latest
Open browser: http://localhost:5000
version: '3.8'
services:
nafnet:
build: .
ports:
- "5000:5000"
environment:
- FLASK_ENV=production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/api/info"]
interval: 30s
timeout: 10s
retries: 3
docker-compose up -d
docker-compose logs -f
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 --timeout 60 app:app
Parameters:
-w 4 - Number of workers (adjust based on CPU cores)-b 0.0.0.0:5000 - Bind to all interfaces on port 5000--timeout 60 - Request timeout in secondsCreate /etc/systemd/system/nafnet.service:
[Unit]
Description=NAFNet Image Restoration API
After=network.target
[Service]
Type=notify
User=www-data
WorkingDirectory=/opt/nafnet
Environment="PATH=/opt/nafnet/venv/bin"
ExecStart=/opt/nafnet/venv/bin/gunicorn -w 4 -b 0.0.0.0:5000 app:app
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable nafnet
sudo systemctl start nafnet
ssh -i key.pem ubuntu@<instance-ip>
# Update system
sudo apt-get update
sudo apt-get upgrade -y
# Install dependencies
sudo apt-get install -y python3-pip python3-venv git
# Clone and setup
git clone https://github.com/Gtajisan/NAFNet-Image-Restoration-API.git
cd NAFNet-Image-Restoration-API
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run with Gunicorn
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app
sudo apt-get install -y nginx
# Create config at /etc/nginx/sites-available/nafnet
sudo nano /etc/nginx/sites-available/nafnet
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
sudo ln -s /etc/nginx/sites-available/nafnet /etc/nginx/sites-enabled/
sudo systemctl restart nginx
npm install -g heroku
heroku login
web: gunicorn app:app
git push heroku main
Replit deployment is automatic - just click the “Publish” button in the web interface.
# Test API info endpoint
curl http://localhost:5000/api/info
# Expected output (JSON)
{
"name": "NAFNet Image Restoration API",
"version": "1.0",
"endpoints": {
"GET /": "Web interface",
"GET /api/info": "Get API info",
"POST /api/fix": "Upload image for restoration"
}
}
# Create test image
python3 << 'EOF'
from PIL import Image
img = Image.new('RGB', (100, 100), color='red')
img.save('test.jpg')
EOF
# Upload and process
curl -X POST -F "file=@test.jpg" \
http://localhost:5000/api/fix \
-o restored.png
# Verify output exists
ls -lh restored.png
Solution:
# Check installation
python3 --version
which python3
# Use python3 instead of python if needed
python3 -m venv venv
Solution:
# Install pip
python3 -m ensurepip --upgrade
# Or upgrade pip
python3 -m pip install --upgrade pip
Solution:
# Run with sudo (not recommended for venv)
sudo pip install -r requirements.txt
# Or fix permissions
chmod +x app.py
Solution:
# Find process using port 5000
lsof -i :5000
# Kill process
kill -9 <PID>
# Or use different port
# Edit app.py: app.run(port=5001)
Solution:
# Reinstall all dependencies
pip install --upgrade -r requirements.txt
# Or individual package
pip install Flask Pillow numpy scipy
Solution:
# For Docker, increase memory limit
docker run -p 5000:5000 -m 2g nafnet-api:latest
# For local, increase system RAM or use Gunicorn workers
gunicorn -w 2 -b 0.0.0.0:5000 app:app # Reduce workers
Solution:
# Clean Docker cache
docker system prune -a
# Rebuild without cache
docker build --no-cache -t nafnet-api:latest .
Optional configuration via environment variables:
# Development
export FLASK_ENV=development
export FLASK_DEBUG=1
# Production
export FLASK_ENV=production
export MAX_CONTENT_LENGTH=52428800 # 50MB in bytes
After successful installation:
For installation issues: