Spaces:
Runtime error
Runtime error
update for video enhance.
Browse files- README.md +7 -2
- basicsr/utils/video_util.py +10 -4
- inference_codeformer.py +3 -0
- requirements.txt +1 -2
README.md
CHANGED
@@ -100,7 +100,7 @@ You can put the testing images in the `inputs/TestWhole` folder. If you would li
|
|
100 |
π§π» Face Restoration (cropped and aligned face)
|
101 |
```
|
102 |
# For cropped and aligned faces
|
103 |
-
python inference_codeformer.py -w 0.5 --has_aligned --input_path [
|
104 |
```
|
105 |
|
106 |
:framed_picture: Whole Image Enhancement
|
@@ -108,12 +108,17 @@ python inference_codeformer.py -w 0.5 --has_aligned --input_path [input folder]
|
|
108 |
# For whole image
|
109 |
# Add '--bg_upsampler realesrgan' to enhance the background regions with Real-ESRGAN
|
110 |
# Add '--face_upsample' to further upsample restorated face with Real-ESRGAN
|
111 |
-
python inference_codeformer.py -w 0.7 --input_path [image folder
|
112 |
```
|
113 |
|
114 |
:clapper: Video Enhancement
|
115 |
```
|
|
|
|
|
|
|
|
|
116 |
# For video clips
|
|
|
117 |
python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path [video path]
|
118 |
```
|
119 |
|
|
|
100 |
π§π» Face Restoration (cropped and aligned face)
|
101 |
```
|
102 |
# For cropped and aligned faces
|
103 |
+
python inference_codeformer.py -w 0.5 --has_aligned --input_path [image folder]|[image path]
|
104 |
```
|
105 |
|
106 |
:framed_picture: Whole Image Enhancement
|
|
|
108 |
# For whole image
|
109 |
# Add '--bg_upsampler realesrgan' to enhance the background regions with Real-ESRGAN
|
110 |
# Add '--face_upsample' to further upsample restorated face with Real-ESRGAN
|
111 |
+
python inference_codeformer.py -w 0.7 --input_path [image folder]|[image path]
|
112 |
```
|
113 |
|
114 |
:clapper: Video Enhancement
|
115 |
```
|
116 |
+
# For Windows/Mac users, please install ffmpeg first
|
117 |
+
conda install -c conda-forge ffmpeg
|
118 |
+
```
|
119 |
+
```
|
120 |
# For video clips
|
121 |
+
# video path should end with '.mp4'|'.mov'|'.avi'
|
122 |
python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path [video path]
|
123 |
```
|
124 |
|
basicsr/utils/video_util.py
CHANGED
@@ -30,10 +30,16 @@ class VideoReader:
|
|
30 |
def __init__(self, video_path):
|
31 |
self.paths = [] # for image&folder type
|
32 |
self.audio = None
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
meta = get_video_meta_info(video_path)
|
38 |
self.width = meta['width']
|
39 |
self.height = meta['height']
|
|
|
30 |
def __init__(self, video_path):
|
31 |
self.paths = [] # for image&folder type
|
32 |
self.audio = None
|
33 |
+
try:
|
34 |
+
self.stream_reader = (
|
35 |
+
ffmpeg.input(video_path).output('pipe:', format='rawvideo', pix_fmt='bgr24',
|
36 |
+
loglevel='error').run_async(
|
37 |
+
pipe_stdin=True, pipe_stdout=True, cmd='ffmpeg'))
|
38 |
+
except FileNotFoundError:
|
39 |
+
print('Please install ffmpeg (not ffmpeg-python) by running\n',
|
40 |
+
'\t$ conda install -c conda-forge ffmpeg')
|
41 |
+
sys.exit(0)
|
42 |
+
|
43 |
meta = get_video_meta_info(video_path)
|
44 |
self.width = meta['width']
|
45 |
self.height = meta['height']
|
inference_codeformer.py
CHANGED
@@ -107,6 +107,9 @@ if __name__ == '__main__':
|
|
107 |
result_root = args.output_path
|
108 |
|
109 |
test_img_num = len(input_img_list)
|
|
|
|
|
|
|
110 |
# ------------------ set up background upsampler ------------------
|
111 |
if args.bg_upsampler == 'realesrgan':
|
112 |
bg_upsampler = set_realesrgan()
|
|
|
107 |
result_root = args.output_path
|
108 |
|
109 |
test_img_num = len(input_img_list)
|
110 |
+
if test_img_num == 0:
|
111 |
+
raise FileNotFoundError("\nInput file is not found.")
|
112 |
+
|
113 |
# ------------------ set up background upsampler ------------------
|
114 |
if args.bg_upsampler == 'realesrgan':
|
115 |
bg_upsampler = set_realesrgan()
|
requirements.txt
CHANGED
@@ -14,5 +14,4 @@ torchvision
|
|
14 |
tqdm
|
15 |
yapf
|
16 |
lpips
|
17 |
-
gdown # supports downloading the large file from Google Drive
|
18 |
-
ffmpeg-python
|
|
|
14 |
tqdm
|
15 |
yapf
|
16 |
lpips
|
17 |
+
gdown # supports downloading the large file from Google Drive
|
|