nagagopalchimata/esrgan-upscaler
0
ESRGAN Super-Resolution API
FastAPI backend serving the xinntao/ESRGAN model, deployed as a permanent Hugging Face Space instead of a temporary Kaggle + ngrok tunnel.
Endpoints
GET /health— check status, confirms model is loaded and which device (cuda/cpu) is in usePOST /upscale— upload an image (multipart form fieldfile), get back the 4x upscaled PNG
One-time setup: add the model weights
This repo does not include RRDB_ESRGAN_x4.pth (the file is too large for a plain git push without LFS). Add it once, after creating this Space:
- Go to your Space page → Files tab → Add file → Upload files
- Create/upload into a
models/folder so the final path is:
models/RRDB_ESRGAN_x4.pth- Commit — the Space will automatically rebuild and restart with the model weights included.
Alternatively, from your local machine with git and git-lfs installed:
git clone https://huggingface.co/spaces/<your-username>/<your-space-name>
cd <your-space-name>
git lfs install
git lfs track "*.pth"
mkdir -p models
cp /path/to/RRDB_ESRGAN_x4.pth models/
git add .gitattributes models/RRDB_ESRGAN_x4.pth
git commit -m "Add ESRGAN weights"
git pushTesting after deploy
curl https://<your-username>-<your-space-name>.hf.space/health
curl -X POST https://<your-username>-<your-space-name>.hf.space/upscale \
-F "file=@comic.png" \
--output upscaled.pngFrontend
Point your React app's API_BASE_URL constant at:
https://<your-username>-<your-space-name>.hf.spaceThis URL is permanent — it does not change on restart, unlike ngrok.
Notes on the free tier
- Free Spaces run on CPU by default, so inference will be slower than the GPU you had on Kaggle. This is fine for testing; if you need faster responses, upgrade the Space's hardware to a GPU tier from the Space settings page (paid, billed per hour while running).
- Free Spaces can go to sleep after a period of inactivity and take a little while to "wake up" on the next request (cold start). This is normal Spaces behavior, not an error in this code.
