Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,17 @@
|
|
| 1 |
-
# ----- Patch شروع -----
|
| 2 |
-
import torchvision.transforms.functional as F
|
| 3 |
-
import sys
|
| 4 |
-
|
| 5 |
-
# اگر functional_tensor وجود نداشت، خودمون شبیهسازی میکنیم
|
| 6 |
-
sys.modules['torchvision.transforms.functional_tensor'] = F
|
| 7 |
-
# ----- Patch پایان -----
|
| 8 |
-
|
| 9 |
from gfpgan import GFPGANer
|
|
|
|
| 10 |
from PIL import Image
|
| 11 |
import gradio as gr
|
| 12 |
|
| 13 |
-
# مدل GFPGAN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
restorer = GFPGANer(
|
| 15 |
-
model_path=
|
| 16 |
upscale=1,
|
| 17 |
arch='clean',
|
| 18 |
channel_multiplier=2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from gfpgan import GFPGANer
|
| 2 |
+
from huggingface_hub import hf_hub_download
|
| 3 |
from PIL import Image
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
# دانلود خودکار مدل GFPGAN از Hugging Face
|
| 7 |
+
model_path = hf_hub_download(
|
| 8 |
+
repo_id="TencentARC/GFPGAN",
|
| 9 |
+
filename="GFPGANv1.4.pth"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
# ساخت Restorer با مسیر مدل
|
| 13 |
restorer = GFPGANer(
|
| 14 |
+
model_path=model_path,
|
| 15 |
upscale=1,
|
| 16 |
arch='clean',
|
| 17 |
channel_multiplier=2,
|