Spaces:
Running
on
T4
Running
on
T4
HikariDawn
commited on
Commit
·
720b377
1
Parent(s):
d26bbd5
feat: update new 4xRRDB weight option
Browse files
app.py
CHANGED
@@ -21,6 +21,10 @@ def auto_download_if_needed(weight_path):
|
|
21 |
if not os.path.exists("pretrained"):
|
22 |
os.makedirs("pretrained")
|
23 |
|
|
|
|
|
|
|
|
|
24 |
if weight_path == "pretrained/4x_APISR_GRL_GAN_generator.pth":
|
25 |
os.system("wget https://github.com/Kiteretsu77/APISR/releases/download/v0.1.0/4x_APISR_GRL_GAN_generator.pth")
|
26 |
os.system("mv 4x_APISR_GRL_GAN_generator.pth pretrained")
|
@@ -29,6 +33,7 @@ def auto_download_if_needed(weight_path):
|
|
29 |
os.system("wget https://github.com/Kiteretsu77/APISR/releases/download/v0.1.0/2x_APISR_RRDB_GAN_generator.pth")
|
30 |
os.system("mv 2x_APISR_RRDB_GAN_generator.pth pretrained")
|
31 |
|
|
|
32 |
|
33 |
|
34 |
def inference(img_path, model_name):
|
@@ -42,6 +47,11 @@ def inference(img_path, model_name):
|
|
42 |
auto_download_if_needed(weight_path)
|
43 |
generator = load_grl(weight_path, scale=4) # Directly use default way now
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
elif model_name == "2xRRDB":
|
46 |
weight_path = "pretrained/2x_APISR_RRDB_GAN_generator.pth"
|
47 |
auto_download_if_needed(weight_path)
|
@@ -80,7 +90,8 @@ if __name__ == '__main__':
|
|
80 |
APISR aims at restoring and enhancing low-quality low-resolution anime images and video sources with various degradations from real-world scenarios.
|
81 |
|
82 |
### Note: Due to memory restriction, all images whose short side is over 720 pixel will be downsampled to 720 pixel with the same aspect ratio. E.g., 1920x1080 -> 1280x720
|
83 |
-
|
|
|
84 |
If APISR is helpful, please help star the GitHub Repo. Thanks!
|
85 |
"""
|
86 |
|
@@ -94,6 +105,7 @@ if __name__ == '__main__':
|
|
94 |
model_name = gr.Dropdown(
|
95 |
[
|
96 |
"2xRRDB",
|
|
|
97 |
"4xGRL"
|
98 |
],
|
99 |
type="value",
|
|
|
21 |
if not os.path.exists("pretrained"):
|
22 |
os.makedirs("pretrained")
|
23 |
|
24 |
+
if weight_path == "pretrained/4x_APISR_RRDB_GAN_generator.pth":
|
25 |
+
os.system("wget https://github.com/Kiteretsu77/APISR/releases/download/v0.2.0/4x_APISR_RRDB_GAN_generator.pth")
|
26 |
+
os.system("mv 4x_APISR_RRDB_GAN_generator.pth pretrained")
|
27 |
+
|
28 |
if weight_path == "pretrained/4x_APISR_GRL_GAN_generator.pth":
|
29 |
os.system("wget https://github.com/Kiteretsu77/APISR/releases/download/v0.1.0/4x_APISR_GRL_GAN_generator.pth")
|
30 |
os.system("mv 4x_APISR_GRL_GAN_generator.pth pretrained")
|
|
|
33 |
os.system("wget https://github.com/Kiteretsu77/APISR/releases/download/v0.1.0/2x_APISR_RRDB_GAN_generator.pth")
|
34 |
os.system("mv 2x_APISR_RRDB_GAN_generator.pth pretrained")
|
35 |
|
36 |
+
|
37 |
|
38 |
|
39 |
def inference(img_path, model_name):
|
|
|
47 |
auto_download_if_needed(weight_path)
|
48 |
generator = load_grl(weight_path, scale=4) # Directly use default way now
|
49 |
|
50 |
+
elif model_name == "4xRRDB":
|
51 |
+
weight_path = "pretrained/4x_APISR_RRDB_GAN_generator.pth"
|
52 |
+
auto_download_if_needed(weight_path)
|
53 |
+
generator = load_rrdb(weight_path, scale=4) # Directly use default way now
|
54 |
+
|
55 |
elif model_name == "2xRRDB":
|
56 |
weight_path = "pretrained/2x_APISR_RRDB_GAN_generator.pth"
|
57 |
auto_download_if_needed(weight_path)
|
|
|
90 |
APISR aims at restoring and enhancing low-quality low-resolution anime images and video sources with various degradations from real-world scenarios.
|
91 |
|
92 |
### Note: Due to memory restriction, all images whose short side is over 720 pixel will be downsampled to 720 pixel with the same aspect ratio. E.g., 1920x1080 -> 1280x720
|
93 |
+
### Note: Please check [Model Zoo](https://github.com/Kiteretsu77/APISR/blob/main/docs/model_zoo.md) for the description of each weight.
|
94 |
+
|
95 |
If APISR is helpful, please help star the GitHub Repo. Thanks!
|
96 |
"""
|
97 |
|
|
|
105 |
model_name = gr.Dropdown(
|
106 |
[
|
107 |
"2xRRDB",
|
108 |
+
"4xRRDB",
|
109 |
"4xGRL"
|
110 |
],
|
111 |
type="value",
|