tjxj commited on
Commit
2a8871c
1 Parent(s): 58e921d

Add application file

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .history/app_20220326215622.py +68 -0
  2. .history/app_20220326225131.py +68 -0
  3. .history/app_20220326225537.py +68 -0
  4. .history/app_20220326225603.py +68 -0
  5. .history/app_20220326225611.py +68 -0
  6. .history/app_20220326225639.py +68 -0
  7. .history/app_20220326230240.py +68 -0
  8. .history/app_20220326230353.py +68 -0
  9. .history/app_20220326230358.py +68 -0
  10. .history/app_20220326230538.py +68 -0
  11. .history/app_20220326231036.py +68 -0
  12. .history/app_20220326232312.py +65 -0
  13. .history/app_20220326233155.py +65 -0
  14. .history/app_20220326233250.py +65 -0
  15. .history/app_20220327000906.py +65 -0
  16. .history/app_20220327001145.py +65 -0
  17. .history/app_20220327001147.py +65 -0
  18. .history/app_20220327001316.py +65 -0
  19. .history/app_20220327001317.py +65 -0
  20. .history/app_20220327001520.py +65 -0
  21. .history/app_20220327001522.py +65 -0
  22. .history/app_20220327001529.py +65 -0
  23. .history/app_20220327001559.py +65 -0
  24. .history/app_20220327001612.py +65 -0
  25. .history/app_20220327001641.py +65 -0
  26. .history/app_20220327002459.py +65 -0
  27. .history/app_20220327002503.py +65 -0
  28. .history/app_20220327002645.py +65 -0
  29. .history/app_20220327002649.py +66 -0
  30. .history/app_20220327002712.py +66 -0
  31. .history/app_20220327002809.py +66 -0
  32. .history/app_20220327002819.py +65 -0
  33. .history/app_20220327002904.py +65 -0
  34. .history/app_20220327003334.py +65 -0
  35. .history/app_20220327003336.py +65 -0
  36. .history/app_20220327003455.py +65 -0
  37. .history/app_20220327003506.py +65 -0
  38. .history/app_20220327003524.py +65 -0
  39. .history/app_20220327003525.py +65 -0
  40. .history/app_20220327003535.py +65 -0
  41. .history/app_20220327003604.py +65 -0
  42. .history/app_20220327003733.py +65 -0
  43. .history/app_20220327003750.py +65 -0
  44. .history/app_20220327003753.py +65 -0
  45. .history/app_20220327003759.py +65 -0
  46. .history/app_20220327004133.py +65 -0
  47. .history/app_20220327004134.py +65 -0
  48. .history/app_20220327004219.py +65 -0
  49. .history/app_20220327004403.py +65 -0
  50. .history/app_20220327004416.py +65 -0
.history/app_20220326215622.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='GFPGANCleanv1-NoCE-C2.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326225131.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='GFPGANCleanv1-NoCE-C2.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326225537.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='GFPGANCleanv1-NoCE-C2.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326225603.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326225611.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326225639.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326230240.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326230353.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326230358.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326230538.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326231036.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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+
42
+
43
+
44
+ def inference(img):
45
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
46
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
47
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
48
+
49
+ return Image.fromarray(restored_faces[0][:,:,::-1])
50
+
51
+ title = "GFP-GAN"
52
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
53
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
54
+ gr.Interface(
55
+ inference,
56
+ [gr.inputs.Image(type="filepath", label="Input")],
57
+ gr.outputs.Image(type="pil", label="Output"),
58
+ title=title,
59
+ description=description,
60
+ article=article,
61
+ examples=[
62
+ ['lincoln.jpg'],
63
+ ['einstein.png'],
64
+ ['edison.jpg'],
65
+ ['Henry.jpg'],
66
+ ['Frida.jpg']
67
+ ]
68
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326232312.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326233155.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220326233250.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327000906.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001145.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-0])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001147.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-0])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001316.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001317.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001520.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001522.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001529.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001559.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001612.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327001641.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img)
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327002459.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_img , restored_faces= restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327002503.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_img , restored_faces= restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327002645.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327002649.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+
49
+ title = "GFP-GAN"
50
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
51
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
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)
.history/app_20220327002712.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+
49
+ title = "GFP-GAN"
50
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
51
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
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)
.history/app_20220327002809.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+
49
+ title = "GFP-GAN"
50
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
51
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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>"
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)
.history/app_20220327002819.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327002904.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003334.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_img , restored_faces= restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_faces[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003336.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_img , restored_faces= restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003455.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_img , restored_faces= restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[1][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003506.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_img , restored_faces= restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[2][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003524.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[2][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003525.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[2][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003535.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[2][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003604.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003733.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-2])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003750.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-2])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003753.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-2])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327003759.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-3])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327004133.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327004134.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ cropped_faces, restored_faces, restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327004219.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327004403.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img)
43
+ restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)
.history/app_20220327004416.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ import cv2
20
+ import glob
21
+ import numpy as np
22
+ from basicsr.utils import imwrite
23
+ from gfpgan import GFPGANer
24
+
25
+ import warnings
26
+ warnings.warn('The unoptimized RealESRGAN is very slow on CPU. We do not use it. '
27
+ 'If you really want to use it, please modify the corresponding codes.')
28
+ bg_upsampler = None
29
+
30
+
31
+
32
+ # set up GFPGAN restorer
33
+ restorer = GFPGANer(
34
+ model_path='experiments/pretrained_models/GFPGANv1.3.pth',
35
+ upscale=2,
36
+ arch='clean',
37
+ channel_multiplier=2,
38
+ bg_upsampler=bg_upsampler)
39
+
40
+
41
+ def inference(img):
42
+ input_img = cv2.imread(img, cv2.IMREAD_COLOR)
43
+ restored_img = restorer.enhance(
44
+ input_img, has_aligned=False, only_center_face=False, paste_back=True)
45
+
46
+ return Image.fromarray(restored_img[0][:,:,::-1])
47
+
48
+ title = "GFP-GAN"
49
+ description = "Gradio demo for GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please click submit only once"
50
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2101.04061' target='_blank'>Towards Real-World Blind Face Restoration with Generative Facial Prior</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
+ gr.Interface(
52
+ inference,
53
+ [gr.inputs.Image(type="filepath", label="Input")],
54
+ gr.outputs.Image(type="pil", label="Output"),
55
+ title=title,
56
+ description=description,
57
+ article=article,
58
+ examples=[
59
+ ['lincoln.jpg'],
60
+ ['einstein.png'],
61
+ ['edison.jpg'],
62
+ ['Henry.jpg'],
63
+ ['Frida.jpg']
64
+ ]
65
+ ).launch(enable_queue=True,cache_examples=True)