Spaces:
Running
on
A10G
Running
on
A10G
Add wget alternative for Windows
#64
by
afrojanoon
- opened
app.py
CHANGED
@@ -6,21 +6,44 @@ import torch
|
|
6 |
from basicsr.archs.srvgg_arch import SRVGGNetCompact
|
7 |
from gfpgan.utils import GFPGANer
|
8 |
from realesrgan.utils import RealESRGANer
|
|
|
9 |
|
10 |
os.system("pip freeze")
|
11 |
# download weights
|
12 |
-
|
13 |
-
|
14 |
-
if not os.path.exists(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
if not os.path.exists('
|
21 |
-
|
22 |
-
if not os.path.exists('
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
torch.hub.download_url_to_file(
|
26 |
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Abraham_Lincoln_O-77_matte_collodion_print.jpg/1024px-Abraham_Lincoln_O-77_matte_collodion_print.jpg',
|
|
|
6 |
from basicsr.archs.srvgg_arch import SRVGGNetCompact
|
7 |
from gfpgan.utils import GFPGANer
|
8 |
from realesrgan.utils import RealESRGANer
|
9 |
+
import urllib.request
|
10 |
|
11 |
os.system("pip freeze")
|
12 |
# download weights
|
13 |
+
|
14 |
+
def download_file(url, output_path):
|
15 |
+
if not os.path.exists(output_path):
|
16 |
+
print(f"Downloading {output_path}...")
|
17 |
+
urllib.request.urlretrieve(url, output_path)
|
18 |
+
|
19 |
+
# Windows doesn't have wget
|
20 |
+
if platform.system() == "Windows":
|
21 |
+
if not os.path.exists('realesr-general-x4v3.pth'):
|
22 |
+
download_file("https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", "realesr-general-x4v3.pth")
|
23 |
+
if not os.path.exists('GFPGANv1.2.pth'):
|
24 |
+
download_file("https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.2.pth", "GFPGANv1.2.pth")
|
25 |
+
if not os.path.exists('GFPGANv1.3.pth'):
|
26 |
+
download_file("https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth", "GFPGANv1.3.pth")
|
27 |
+
if not os.path.exists('GFPGANv1.4.pth'):
|
28 |
+
download_file("https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth", "GFPGANv1.4.pth")
|
29 |
+
if not os.path.exists('RestoreFormer.pth'):
|
30 |
+
download_file("https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/RestoreFormer.pth", "RestoreFormer.pth")
|
31 |
+
if not os.path.exists('CodeFormer.pth'):
|
32 |
+
download_file("https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/CodeFormer.pth", "CodeFormer.pth")
|
33 |
+
else:
|
34 |
+
if not os.path.exists('realesr-general-x4v3.pth'):
|
35 |
+
os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P .")
|
36 |
+
if not os.path.exists('GFPGANv1.2.pth'):
|
37 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.2.pth -P .")
|
38 |
+
if not os.path.exists('GFPGANv1.3.pth'):
|
39 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P .")
|
40 |
+
if not os.path.exists('GFPGANv1.4.pth'):
|
41 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth -P .")
|
42 |
+
if not os.path.exists('RestoreFormer.pth'):
|
43 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/RestoreFormer.pth -P .")
|
44 |
+
if not os.path.exists('CodeFormer.pth'):
|
45 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/CodeFormer.pth -P .")
|
46 |
+
|
47 |
|
48 |
torch.hub.download_url_to_file(
|
49 |
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Abraham_Lincoln_O-77_matte_collodion_print.jpg/1024px-Abraham_Lincoln_O-77_matte_collodion_print.jpg',
|