Spaces:
Running
Running
mt2nwdn commited on
Commit ·
7adb383
1
Parent(s): b754303
Update deployment to use Docker instead of Gradio
Browse filesRefactor the project to utilize a Docker-based deployment strategy, updating README.md and enhancer.py, and introducing a Dockerfile for building and running the application container.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: bbef0274-cbeb-475e-9405-87aa3768f3bb
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: 580f61c3-f9a0-4a7a-90e0-d6444760c3aa
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7d1cb5bc-d8ee-4ca0-b38d-ea189c447bda/bbef0274-cbeb-475e-9405-87aa3768f3bb/uSFrCbs
- Dockerfile +22 -0
- README.md +3 -5
- enhancer.py +2 -9
Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
libgl1-mesa-glx \
|
| 7 |
+
libglib2.0-0 \
|
| 8 |
+
wget \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
COPY requirements.txt .
|
| 12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
+
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
RUN mkdir -p uploads outputs weights templates
|
| 17 |
+
|
| 18 |
+
EXPOSE 7860
|
| 19 |
+
|
| 20 |
+
ENV PYTHONUNBUFFERED=1
|
| 21 |
+
|
| 22 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -3,9 +3,7 @@ title: AI Image Enhancer
|
|
| 3 |
emoji: 🖼️
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: 4.0.0
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
---
|
|
@@ -76,9 +74,9 @@ The server will start at `http://localhost:7860`
|
|
| 76 |
## Deployment to Hugging Face Spaces
|
| 77 |
|
| 78 |
1. Create a new Space on Hugging Face
|
| 79 |
-
2. Select "
|
| 80 |
3. Upload all files from this repository
|
| 81 |
-
4. The Space will automatically
|
| 82 |
|
| 83 |
## API Usage Examples
|
| 84 |
|
|
|
|
| 3 |
emoji: 🖼️
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
---
|
|
|
|
| 74 |
## Deployment to Hugging Face Spaces
|
| 75 |
|
| 76 |
1. Create a new Space on Hugging Face
|
| 77 |
+
2. Select "Docker" as the SDK
|
| 78 |
3. Upload all files from this repository
|
| 79 |
+
4. The Space will automatically build and start the container
|
| 80 |
|
| 81 |
## API Usage Examples
|
| 82 |
|
enhancer.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
import torch
|
| 3 |
import numpy as np
|
| 4 |
from PIL import Image
|
|
@@ -22,14 +21,8 @@ class ImageEnhancer:
|
|
| 22 |
|
| 23 |
def _load_model(self):
|
| 24 |
"""Download and load the Real-ESRGAN model."""
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
from basicsr.archs.rrdbnet_arch import RRDBNet
|
| 28 |
-
except ImportError:
|
| 29 |
-
print("Installing Real-ESRGAN dependencies...")
|
| 30 |
-
os.system("pip install realesrgan basicsr")
|
| 31 |
-
from realesrgan import RealESRGANer
|
| 32 |
-
from basicsr.archs.rrdbnet_arch import RRDBNet
|
| 33 |
|
| 34 |
model_path = Path("weights")
|
| 35 |
model_path.mkdir(exist_ok=True)
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
|
|
|
| 21 |
|
| 22 |
def _load_model(self):
|
| 23 |
"""Download and load the Real-ESRGAN model."""
|
| 24 |
+
from realesrgan import RealESRGANer
|
| 25 |
+
from basicsr.archs.rrdbnet_arch import RRDBNet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
model_path = Path("weights")
|
| 28 |
model_path.mkdir(exist_ok=True)
|