add datetime to output files to prevent conflict
Browse files- FGT_codes/tool/video_inpainting.py +1 -1
- app.py +11 -3
FGT_codes/tool/video_inpainting.py
CHANGED
@@ -776,7 +776,7 @@ def video_inpainting(args, imgArr, imgMaskArr):
|
|
776 |
for i in range(len(comp_frames)):
|
777 |
comp_frames[i] = comp_frames[i].astype(np.uint8)
|
778 |
imageio.mimwrite(
|
779 |
-
os.path.join(args.outroot,
|
780 |
)
|
781 |
print(f"Done, please check your result in {args.outroot} ")
|
782 |
|
|
|
776 |
for i in range(len(comp_frames)):
|
777 |
comp_frames[i] = comp_frames[i].astype(np.uint8)
|
778 |
imageio.mimwrite(
|
779 |
+
os.path.join(args.outroot, args.outfilename), comp_frames, fps=args.out_fps, quality=8
|
780 |
)
|
781 |
print(f"Done, please check your result in {args.outroot} ")
|
782 |
|
app.py
CHANGED
@@ -12,6 +12,7 @@ import sys
|
|
12 |
from os.path import exists, join, basename, splitext
|
13 |
import os
|
14 |
import argparse
|
|
|
15 |
|
16 |
project_name = ''
|
17 |
|
@@ -46,6 +47,11 @@ siammask = Custom(anchors=cfg['anchors'])
|
|
46 |
siammask = load_pretrain(siammask, pretrained_path1)
|
47 |
siammask = siammask.eval().to(device)
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
# constants
|
50 |
object_x = 0
|
51 |
object_y = 0
|
@@ -69,6 +75,8 @@ parser.add_argument(
|
|
69 |
'--path_mask', default='/myData/dilateAnnotations_4/walking', help="mask for object removal")
|
70 |
parser.add_argument(
|
71 |
'--outroot', default=os.path.abspath(project_name), help="output directory")
|
|
|
|
|
72 |
parser.add_argument('--consistencyThres', dest='consistencyThres', default=5, type=float,
|
73 |
help='flow consistency error threshold')
|
74 |
parser.add_argument('--alpha', dest='alpha', default=0.1, type=float)
|
@@ -156,7 +164,7 @@ def track_and_mask(vid, original_frame, masked_frame):
|
|
156 |
in_fps = fps
|
157 |
# can't write out mp4, so try to write into an AVI file
|
158 |
video_writer = cv2.VideoWriter(
|
159 |
-
"
|
160 |
|
161 |
while video_capture.isOpened():
|
162 |
ret, frame = video_capture.read()
|
@@ -198,14 +206,14 @@ def track_and_mask(vid, original_frame, masked_frame):
|
|
198 |
|
199 |
print('Original Frame Count: ',len(original_frame_list))
|
200 |
print('Mask Frame Count: ',len(mask_list))
|
201 |
-
return "
|
202 |
|
203 |
|
204 |
def inpaint_video():
|
205 |
args.out_fps = in_fps
|
206 |
video_inpainting(args, original_frame_list, mask_list)
|
207 |
|
208 |
-
return "
|
209 |
|
210 |
|
211 |
def get_first_frame(video):
|
|
|
12 |
from os.path import exists, join, basename, splitext
|
13 |
import os
|
14 |
import argparse
|
15 |
+
from datetime import datetime
|
16 |
|
17 |
project_name = ''
|
18 |
|
|
|
47 |
siammask = load_pretrain(siammask, pretrained_path1)
|
48 |
siammask = siammask.eval().to(device)
|
49 |
|
50 |
+
# datetime object containing current date and time
|
51 |
+
now = datetime.now()
|
52 |
+
|
53 |
+
dt_string = now.strftime("%d_%m_%Y_%H_%M_%S")
|
54 |
+
print("date and time =", dt_string)
|
55 |
# constants
|
56 |
object_x = 0
|
57 |
object_y = 0
|
|
|
75 |
'--path_mask', default='/myData/dilateAnnotations_4/walking', help="mask for object removal")
|
76 |
parser.add_argument(
|
77 |
'--outroot', default=os.path.abspath(project_name), help="output directory")
|
78 |
+
parser.add_argument(
|
79 |
+
'--outfilename', default=dt_string+"_result.mp4", help="output filename")
|
80 |
parser.add_argument('--consistencyThres', dest='consistencyThres', default=5, type=float,
|
81 |
help='flow consistency error threshold')
|
82 |
parser.add_argument('--alpha', dest='alpha', default=0.1, type=float)
|
|
|
164 |
in_fps = fps
|
165 |
# can't write out mp4, so try to write into an AVI file
|
166 |
video_writer = cv2.VideoWriter(
|
167 |
+
dt_string+"_output.avi", cv2.VideoWriter_fourcc(*'MP42'), fps, (width, height))
|
168 |
|
169 |
while video_capture.isOpened():
|
170 |
ret, frame = video_capture.read()
|
|
|
206 |
|
207 |
print('Original Frame Count: ',len(original_frame_list))
|
208 |
print('Mask Frame Count: ',len(mask_list))
|
209 |
+
return dt_string+"_output.avi"
|
210 |
|
211 |
|
212 |
def inpaint_video():
|
213 |
args.out_fps = in_fps
|
214 |
video_inpainting(args, original_frame_list, mask_list)
|
215 |
|
216 |
+
return dt_string+"_result.mp4"
|
217 |
|
218 |
|
219 |
def get_first_frame(video):
|