Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,17 +23,17 @@ if not os.path.exists('CodeFormer.pth'):
|
|
| 23 |
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/CodeFormer.pth -P .")
|
| 24 |
|
| 25 |
torch.hub.download_url_to_file(
|
| 26 |
-
'https://
|
| 27 |
-
'
|
| 28 |
torch.hub.download_url_to_file(
|
| 29 |
-
'https://
|
| 30 |
-
'
|
| 31 |
torch.hub.download_url_to_file(
|
| 32 |
-
'https://
|
| 33 |
-
'
|
| 34 |
torch.hub.download_url_to_file(
|
| 35 |
-
'https://
|
| 36 |
-
'
|
| 37 |
|
| 38 |
# background enhancer with RealESRGAN
|
| 39 |
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
|
@@ -75,9 +75,12 @@ def inference(img, version, scale):
|
|
| 75 |
elif version == 'RestoreFormer':
|
| 76 |
face_enhancer = GFPGANer(
|
| 77 |
model_path='RestoreFormer.pth', upscale=2, arch='RestoreFormer', channel_multiplier=2, bg_upsampler=upsampler)
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
try:
|
| 83 |
# _, _, output = face_enhancer.enhance(img, has_aligned=False, only_center_face=False, paste_back=True, weight=weight)
|
|
@@ -121,7 +124,7 @@ demo = gr.Interface(
|
|
| 121 |
inference, [
|
| 122 |
gr.inputs.Image(type="filepath", label="Input"),
|
| 123 |
# gr.inputs.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer', 'CodeFormer'], type="value", default='v1.4', label='version'),
|
| 124 |
-
gr.inputs.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer'], type="value", default='v1.4', label='version'),
|
| 125 |
gr.inputs.Number(label="Rescaling factor", default=2),
|
| 126 |
# gr.Slider(0, 100, label='Weight, only for CodeFormer. 0 for better quality, 100 for better identity', default=50)
|
| 127 |
], [
|
|
@@ -133,7 +136,7 @@ demo = gr.Interface(
|
|
| 133 |
article=article,
|
| 134 |
# examples=[['AI-generate.jpg', 'v1.4', 2, 50], ['lincoln.jpg', 'v1.4', 2, 50], ['Blake_Lively.jpg', 'v1.4', 2, 50],
|
| 135 |
# ['10045.png', 'v1.4', 2, 50]]).launch()
|
| 136 |
-
examples=[['
|
| 137 |
-
|
| 138 |
demo.queue(concurrency_count=4)
|
| 139 |
demo.launch()
|
|
|
|
| 23 |
os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/CodeFormer.pth -P .")
|
| 24 |
|
| 25 |
torch.hub.download_url_to_file(
|
| 26 |
+
'https://static.toiimg.com/photo/msid-71531342/71531342.jpg',
|
| 27 |
+
'a1.jpg')
|
| 28 |
torch.hub.download_url_to_file(
|
| 29 |
+
'https://www.deccanherald.com/sites/dh/files/styles/gallery_thumbnails/public/gallery_images/2021/09/17/PM%20Modi%20Rare%20Photos%20%284%29.jpg',
|
| 30 |
+
'a2.jpg')
|
| 31 |
torch.hub.download_url_to_file(
|
| 32 |
+
'https://resize.indiatvnews.com/en/resize/newbucket/715_-/2018/01/dssd-1514798177.jpg',
|
| 33 |
+
'a3.jpg')
|
| 34 |
torch.hub.download_url_to_file(
|
| 35 |
+
'https://resize.indiatvnews.com/en/resize/newbucket/715_-/2018/01/capture-1514798177.jpg',
|
| 36 |
+
'a4.jpg')
|
| 37 |
|
| 38 |
# background enhancer with RealESRGAN
|
| 39 |
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
|
|
|
| 75 |
elif version == 'RestoreFormer':
|
| 76 |
face_enhancer = GFPGANer(
|
| 77 |
model_path='RestoreFormer.pth', upscale=2, arch='RestoreFormer', channel_multiplier=2, bg_upsampler=upsampler)
|
| 78 |
+
elif version == 'CodeFormer':
|
| 79 |
+
face_enhancer = GFPGANer(
|
| 80 |
+
model_path='CodeFormer.pth', upscale=2, arch='CodeFormer', channel_multiplier=2, bg_upsampler=upsampler)
|
| 81 |
+
elif version == 'RealESR-General-x4v3':
|
| 82 |
+
face_enhancer = GFPGANer(
|
| 83 |
+
model_path='realesr-general-x4v3.pth', upscale=2, arch='realesr-general', channel_multiplier=2, bg_upsampler=upsampler)
|
| 84 |
|
| 85 |
try:
|
| 86 |
# _, _, output = face_enhancer.enhance(img, has_aligned=False, only_center_face=False, paste_back=True, weight=weight)
|
|
|
|
| 124 |
inference, [
|
| 125 |
gr.inputs.Image(type="filepath", label="Input"),
|
| 126 |
# gr.inputs.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer', 'CodeFormer'], type="value", default='v1.4', label='version'),
|
| 127 |
+
gr.inputs.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer','CodeFormer','RealESR-General-x4v3'], type="value", default='v1.4', label='version'),
|
| 128 |
gr.inputs.Number(label="Rescaling factor", default=2),
|
| 129 |
# gr.Slider(0, 100, label='Weight, only for CodeFormer. 0 for better quality, 100 for better identity', default=50)
|
| 130 |
], [
|
|
|
|
| 136 |
article=article,
|
| 137 |
# examples=[['AI-generate.jpg', 'v1.4', 2, 50], ['lincoln.jpg', 'v1.4', 2, 50], ['Blake_Lively.jpg', 'v1.4', 2, 50],
|
| 138 |
# ['10045.png', 'v1.4', 2, 50]]).launch()
|
| 139 |
+
examples=[['a1.jpg', 'v1.4', 2], ['a2.jpg', 'v1.4', 2], ['a3.jpg', 'v1.4', 2],['a4.jpg', 'v1.4', 2]])
|
| 140 |
+
|
| 141 |
demo.queue(concurrency_count=4)
|
| 142 |
demo.launch()
|