tjxj commited on
Commit
7b48913
1 Parent(s): 5408b74
.history/app_20220327195546.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip install gfpgan")
3
+
4
+ #os.system("pip freeze")
5
+ #os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth -P .")
6
+ import random
7
+ import gradio as gr
8
+ from PIL import Image
9
+ import torch
10
+ # torch.hub.download_url_to_file('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', 'lincoln.jpg')
11
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/5/50/Albert_Einstein_%28Nobel%29.png', 'einstein.png')
12
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Thomas_Edison2.jpg/1024px-Thomas_Edison2.jpg', 'edison.jpg')
13
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Henry_Ford_1888.jpg/1024px-Henry_Ford_1888.jpg', 'Henry.jpg')
14
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/0/06/Frida_Kahlo%2C_by_Guillermo_Kahlo.jpg/800px-Frida_Kahlo%2C_by_Guillermo_Kahlo.jpg', 'Frida.jpg')
15
+
16
+
17
+ import cv2
18
+ import glob
19
+ import numpy as np
20
+ from basicsr.utils import imwrite
21
+ from gfpgan import GFPGANer
22
+
23
+ bg_upsampler = None
24
+
25
+
26
+
27
+ # set up GFPGAN restorer
28
+ restorer = GFPGANer(
29
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
30
+ upscale=2,
31
+ arch='clean',
32
+ channel_multiplier=2,
33
+ bg_upsampler=bg_upsampler)
34
+
35
+
36
+ def inference(img):
37
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
38
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
39
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
40
+
41
+ #return Image.fromarray(restored_faces[0][:,:,::-1])
42
+ return Image.fromarray(restored_img[:, :, ::-1])
43
+
44
+ title = "让美好回忆更清晰"
45
+
46
+
47
+ description = "上传老照片,点击Submit,稍等片刻,右侧Output将照片另存为即可。"
48
+ article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq`@huggingface</a> </p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
49
+
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'论文地址 By 腾讯PCG</a> | <a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq`@huggingface</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
51
+
52
+ gr.Interface(
53
+ inference,
54
+ [gr.inputs.Image(type="filepath", label="Input")],
55
+ gr.outputs.Image(type="pil", label="Output"),
56
+ title=title,
57
+ description=description,
58
+ article=article,
59
+ examples=[
60
+ ['lincoln.jpg'],
61
+ ['einstein.png'],
62
+ ['edison.jpg'],
63
+ ['Henry.jpg'],
64
+ ['Frida.jpg']
65
+ ]
66
+ ).launch(enable_queue=True,cache_examples=True,share=True)
67
+
68
+
.history/app_20220327195551.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip install gfpgan")
3
+
4
+ #os.system("pip freeze")
5
+ #os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth -P .")
6
+ import random
7
+ import gradio as gr
8
+ from PIL import Image
9
+ import torch
10
+ # torch.hub.download_url_to_file('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', 'lincoln.jpg')
11
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/5/50/Albert_Einstein_%28Nobel%29.png', 'einstein.png')
12
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Thomas_Edison2.jpg/1024px-Thomas_Edison2.jpg', 'edison.jpg')
13
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Henry_Ford_1888.jpg/1024px-Henry_Ford_1888.jpg', 'Henry.jpg')
14
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/0/06/Frida_Kahlo%2C_by_Guillermo_Kahlo.jpg/800px-Frida_Kahlo%2C_by_Guillermo_Kahlo.jpg', 'Frida.jpg')
15
+
16
+
17
+ import cv2
18
+ import glob
19
+ import numpy as np
20
+ from basicsr.utils import imwrite
21
+ from gfpgan import GFPGANer
22
+
23
+ bg_upsampler = None
24
+
25
+
26
+
27
+ # set up GFPGAN restorer
28
+ restorer = GFPGANer(
29
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
30
+ upscale=2,
31
+ arch='clean',
32
+ channel_multiplier=2,
33
+ bg_upsampler=bg_upsampler)
34
+
35
+
36
+ def inference(img):
37
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
38
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
39
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
40
+
41
+ #return Image.fromarray(restored_faces[0][:,:,::-1])
42
+ return Image.fromarray(restored_img[:, :, ::-1])
43
+
44
+ title = "让美好回忆更清晰"
45
+
46
+
47
+ description = "上传老照片,点击Submit,稍等片刻,右侧Output将照片另存为即可。"
48
+ article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq`@huggingface</a> </p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
49
+
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'论文地址 By 腾讯PCG</a> | <a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq`@huggingface</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
51
+
52
+ gr.Interface(
53
+ inference,
54
+ [gr.inputs.Image(type="filepath", label="Input")],
55
+ gr.outputs.Image(type="pil", label="Output"),
56
+ title=title,
57
+ description=description,
58
+ article=article,
59
+ examples=[
60
+ ['lincoln.jpg'],
61
+ ['einstein.png'],
62
+ ['edison.jpg'],
63
+ ['Henry.jpg'],
64
+ ['Frida.jpg']
65
+ ]
66
+ ).launch(enable_queue=True,cache_examples=True,share=True)
67
+
68
+
.history/app_20220327195556.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip install gfpgan")
3
+
4
+ #os.system("pip freeze")
5
+ #os.system("wget https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth -P .")
6
+ import random
7
+ import gradio as gr
8
+ from PIL import Image
9
+ import torch
10
+ # torch.hub.download_url_to_file('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', 'lincoln.jpg')
11
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/5/50/Albert_Einstein_%28Nobel%29.png', 'einstein.png')
12
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Thomas_Edison2.jpg/1024px-Thomas_Edison2.jpg', 'edison.jpg')
13
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Henry_Ford_1888.jpg/1024px-Henry_Ford_1888.jpg', 'Henry.jpg')
14
+ # torch.hub.download_url_to_file('https://upload.wikimedia.org/wikipedia/commons/thumb/0/06/Frida_Kahlo%2C_by_Guillermo_Kahlo.jpg/800px-Frida_Kahlo%2C_by_Guillermo_Kahlo.jpg', 'Frida.jpg')
15
+
16
+
17
+ import cv2
18
+ import glob
19
+ import numpy as np
20
+ from basicsr.utils import imwrite
21
+ from gfpgan import GFPGANer
22
+
23
+ bg_upsampler = None
24
+
25
+
26
+
27
+ # set up GFPGAN restorer
28
+ restorer = GFPGANer(
29
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
30
+ upscale=2,
31
+ arch='clean',
32
+ channel_multiplier=2,
33
+ bg_upsampler=bg_upsampler)
34
+
35
+
36
+ def inference(img):
37
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
38
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
39
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
40
+
41
+ #return Image.fromarray(restored_faces[0][:,:,::-1])
42
+ return Image.fromarray(restored_img[:, :, ::-1])
43
+
44
+ title = "让美好回忆更清晰"
45
+
46
+
47
+ description = "上传老照片,点击Submit,稍等片刻,右侧Output将照片另存为即可。"
48
+ article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq`@huggingface</a> </p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
49
+
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'论文地址 By 腾讯PCG</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
51
+
52
+ gr.Interface(
53
+ inference,
54
+ [gr.inputs.Image(type="filepath", label="Input")],
55
+ gr.outputs.Image(type="pil", label="Output"),
56
+ title=title,
57
+ description=description,
58
+ article=article,
59
+ examples=[
60
+ ['lincoln.jpg'],
61
+ ['einstein.png'],
62
+ ['edison.jpg'],
63
+ ['Henry.jpg'],
64
+ ['Frida.jpg']
65
+ ]
66
+ ).launch(enable_queue=True,cache_examples=True,share=True)
67
+
68
+
app.py CHANGED
@@ -45,7 +45,9 @@ title = "让美好回忆更清晰"
45
 
46
 
47
  description = "上传老照片,点击Submit,稍等片刻,右侧Output将照片另存为即可。"
48
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'论文地址 By 腾讯PCG</a> | <a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq@huggingface</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
 
 
49
 
50
  gr.Interface(
51
  inference,
 
45
 
46
 
47
  description = "上传老照片,点击Submit,稍等片刻,右侧Output将照片另存为即可。"
48
+ article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'本项目克隆自akhaliq`@huggingface</a> </p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
49
+
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'论文地址 By 腾讯PCG</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>"
51
 
52
  gr.Interface(
53
  inference,