Skip to content

Commit ccafc2a

Browse files
feat: Post processing implement in image and video generator
1 parent 94efc01 commit ccafc2a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/modules/image_generate.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
2-
import numpy as np
32

3+
import numpy as np
44
import torch
55
import torchvision.utils as vutils
6-
6+
import cv2
77
from PIL import Image
88
from tqdm import tqdm
99

@@ -29,6 +29,10 @@ def tensor_to_PIL_image(img_tensor):
2929
img_array = img_tensor.clone().detach().cpu().numpy()
3030
img_array = img_array.transpose(1, 2, 0)
3131
img_array = (img_array * 255).round().astype(np.uint8)
32+
33+
# Post processing
34+
img_array = cv2.GaussianBlur(img_array, (5, 5), 0)
35+
3236
return Image.fromarray(img_array)
3337

3438

src/modules/video_generate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def main(train_params, video_params, path_data, path_videos_generated, upscale_w
9292
if upscale_width:
9393
frame = process_and_resize_image(frame, new_width=upscale_width)
9494

95+
# Post processing
96+
frame = cv2.GaussianBlur(frame, (5, 5), 0)
97+
9598
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
9699
out.write(frame)
97100

0 commit comments

Comments
 (0)