Spaces:
Runtime error
Runtime error
Xintao
commited on
Commit
·
0710318
1
Parent(s):
bdea2c9
clean version
Browse files- README.md +1 -1
- app.py +7 -10
- requirements.txt +2 -0
- weights/PutWeightsHere +0 -0
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 😁
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.1.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.1.7
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app.py
CHANGED
|
@@ -9,9 +9,9 @@ from realesrgan.utils import RealESRGANer
|
|
| 9 |
|
| 10 |
os.system("pip freeze")
|
| 11 |
os.system(
|
| 12 |
-
"wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P
|
| 13 |
-
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.2.pth -P
|
| 14 |
-
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P
|
| 15 |
|
| 16 |
torch.hub.download_url_to_file(
|
| 17 |
'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',
|
|
@@ -26,21 +26,18 @@ torch.hub.download_url_to_file(
|
|
| 26 |
'https://user-images.githubusercontent.com/17445847/187401133-8a3bf269-5b4d-4432-b2f0-6d26ee1d3307.png',
|
| 27 |
'10045.jpg')
|
| 28 |
|
| 29 |
-
# determine models according to model names
|
| 30 |
-
|
| 31 |
-
|
| 32 |
# background enhancer with RealESRGAN
|
| 33 |
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
| 34 |
netscale = 4
|
| 35 |
-
model_path =
|
| 36 |
half = True if torch.cuda.is_available() else False
|
| 37 |
upsampler = RealESRGANer(scale=netscale, model_path=model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=half)
|
| 38 |
|
| 39 |
# Use GFPGAN for face enhancement
|
| 40 |
face_enhancer_v3 = GFPGANer(
|
| 41 |
-
model_path='
|
| 42 |
face_enhancer_v2 = GFPGANer(
|
| 43 |
-
model_path='
|
| 44 |
os.makedirs('output', exist_ok=True)
|
| 45 |
|
| 46 |
def inference(img, version, scale):
|
|
@@ -109,4 +106,4 @@ gr.Interface(
|
|
| 109 |
title=title,
|
| 110 |
description=description,
|
| 111 |
article=article,
|
| 112 |
-
examples=[['AI-generate.jpg', 'v1.3', 2], ['lincoln.png', 'v1.3',2], ['Blake_Lively.jpg', 'v1.3',2], ['10045.jpg', 'v1.3',2]).launch()
|
|
|
|
| 9 |
|
| 10 |
os.system("pip freeze")
|
| 11 |
os.system(
|
| 12 |
+
"wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth -P .")
|
| 13 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.2.pth -P .")
|
| 14 |
+
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P .")
|
| 15 |
|
| 16 |
torch.hub.download_url_to_file(
|
| 17 |
'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',
|
|
|
|
| 26 |
'https://user-images.githubusercontent.com/17445847/187401133-8a3bf269-5b4d-4432-b2f0-6d26ee1d3307.png',
|
| 27 |
'10045.jpg')
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
# background enhancer with RealESRGAN
|
| 30 |
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
| 31 |
netscale = 4
|
| 32 |
+
model_path = 'realesr-general-x4v3.pth'
|
| 33 |
half = True if torch.cuda.is_available() else False
|
| 34 |
upsampler = RealESRGANer(scale=netscale, model_path=model_path, model=model, tile=0, tile_pad=10, pre_pad=0, half=half)
|
| 35 |
|
| 36 |
# Use GFPGAN for face enhancement
|
| 37 |
face_enhancer_v3 = GFPGANer(
|
| 38 |
+
model_path='GFPGANv1.3.pth', upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=upsampler)
|
| 39 |
face_enhancer_v2 = GFPGANer(
|
| 40 |
+
model_path='GFPGANv1.2.pth', upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=upsampler)
|
| 41 |
os.makedirs('output', exist_ok=True)
|
| 42 |
|
| 43 |
def inference(img, version, scale):
|
|
|
|
| 106 |
title=title,
|
| 107 |
description=description,
|
| 108 |
article=article,
|
| 109 |
+
examples=[['AI-generate.jpg', 'v1.3', 2], ['lincoln.png', 'v1.3',2], ['Blake_Lively.jpg', 'v1.3',2], ['10045.jpg', 'v1.3',2]]).launch()
|
requirements.txt
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
torch>=1.7
|
| 2 |
basicsr>=1.4.2
|
| 3 |
facexlib>=0.2.4
|
|
|
|
|
|
|
| 4 |
numpy
|
| 5 |
opencv-python
|
| 6 |
torchvision
|
|
|
|
| 1 |
torch>=1.7
|
| 2 |
basicsr>=1.4.2
|
| 3 |
facexlib>=0.2.4
|
| 4 |
+
gfpgan>=1.3.4
|
| 5 |
+
realesrgan>=0.2.5
|
| 6 |
numpy
|
| 7 |
opencv-python
|
| 8 |
torchvision
|
weights/PutWeightsHere
DELETED
|
File without changes
|