CoolFace
Apppublic

nagagopalchimata/esrgan-upscaler

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
App README

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 use
  • —POST /upscale — upload an image (multipart form field file), 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:

  1. 1.Go to your Space page → Files tab → Add file → Upload files
  2. 2.Create/upload into a models/ folder so the final path is:
   models/RRDB_ESRGAN_x4.pth
  1. 1.Commit — the Space will automatically rebuild and restart with the model weights included.

Alternatively, from your local machine with git and git-lfs installed:

bash
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 push

Testing after deploy

bash
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.png

Frontend

Point your React app's API_BASE_URL constant at:

https://<your-username>-<your-space-name>.hf.space

This 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.