Spaces:
Build error
Build error
Initial Upscayl-Web (Gradio) on HF Spaces
Browse files- Dockerfile +22 -0
- app.py +24 -0
- requirements.txt +10 -0
Dockerfile
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# CUDA 11.8 runtime مناسب لـ GPU T4
|
2 |
+
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
|
3 |
+
|
4 |
+
# أدوات أساسية + Python
|
5 |
+
RUN apt-get update && apt-get install -y python3-pip python3-dev git ffmpeg \
|
6 |
+
&& rm -rf /var/lib/apt/lists/*
|
7 |
+
|
8 |
+
# مستخدم غير جذري
|
9 |
+
RUN useradd -m -u 1000 user
|
10 |
+
USER user
|
11 |
+
WORKDIR /app
|
12 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
13 |
+
|
14 |
+
# متطلبات بايثون
|
15 |
+
COPY --chown=user requirements.txt .
|
16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
+
|
18 |
+
# كود التطبيق
|
19 |
+
COPY --chown=user . /app
|
20 |
+
|
21 |
+
EXPOSE 7860
|
22 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from PIL import Image
|
4 |
+
from realesrgan import RealESRGAN
|
5 |
+
|
6 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
7 |
+
|
8 |
+
# حمّل النموذج ووزنه (يُنزَّل تلقائياً أول مرة)
|
9 |
+
model = RealESRGAN(device, scale=4)
|
10 |
+
model.load_weights("RealESRGAN_x4plus.pth", download=True)
|
11 |
+
|
12 |
+
def upscale(img: Image.Image) -> Image.Image:
|
13 |
+
return model.predict(img)
|
14 |
+
|
15 |
+
demo = gr.Interface(
|
16 |
+
fn=upscale,
|
17 |
+
inputs=gr.Image(type="pil", label="Upload image"),
|
18 |
+
outputs=gr.Image(type="pil", label="Upscaled ×4"),
|
19 |
+
title="Upscayl-Web",
|
20 |
+
description="Open-source image upscaler powered by Real-ESRGAN (×4).",
|
21 |
+
)
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# واجهة المستخدم
|
2 |
+
gradio>=4.29
|
3 |
+
|
4 |
+
# نموذج Real-ESRGAN (بايثون – PyTorch)
|
5 |
+
realesrgan
|
6 |
+
gfpgan # اختيارى لتحسين الوجوه
|
7 |
+
|
8 |
+
# أساسيات
|
9 |
+
torch==2.1.2+cu118 --index-url https://download.pytorch.org/whl/cu118
|
10 |
+
pillow
|