未验证 提交 62ce17fc 编写于 作者: L LielinJiang 提交者: GitHub

Fix predictor bug on windows (#209)

* fix windows bug
上级 5b3267bc
......@@ -78,7 +78,7 @@ class DAINPredictor(BasePredictor):
out_path = video2frames(video_path, frame_path_input)
vidname = video_path.split('/')[-1].split('.')[0]
vidname = video_path.split(os.sep)[-1].split('.')[0]
frames = sorted(glob.glob(os.path.join(out_path, '*.png')))
......@@ -122,8 +122,8 @@ class DAINPredictor(BasePredictor):
for i in tqdm(range(frame_num - 1)):
first = frames[i]
second = frames[i + 1]
first_index = int(first.split('/')[-1].split('.')[-2])
second_index = int(second.split('/')[-1].split('.')[-2])
first_index = int(first.split(os.sep)[-1].split('.')[-2])
second_index = int(second.split(os.sep)[-1].split('.')[-2])
img_first = imread(first)
img_second = imread(second)
......@@ -224,7 +224,7 @@ class DAINPredictor(BasePredictor):
for i in range(num1):
src = frames1[i]
imgname = int(src.split('/')[-1].split('.')[-2])
imgname = int(src.split(os.sep)[-1].split('.')[-2])
assert i == imgname
dst = os.path.join(combined,
'{:08d}.png'.format(i * (num_frames + 1)))
......@@ -249,14 +249,14 @@ class DAINPredictor(BasePredictor):
for i in range(num1):
src = frames1[i]
index = int(src.split('/')[-1].split('.')[-2])
index = int(src.split(os.sep)[-1].split('.')[-2])
dst = os.path.join(combined,
'{:08d}.png'.format(times_interp * index))
shutil.copy2(src, dst)
for i in range(num2):
src = frames2[i]
imgname = src.split('/')[-1]
imgname = src.split(os.sep)[-1]
dst = os.path.join(combined, imgname)
shutil.copy2(src, dst)
......@@ -279,9 +279,10 @@ class DAINPredictor(BasePredictor):
for (h, hashed_paths) in hashes.items():
if len(hashed_paths) > 1:
first_index = int(hashed_paths[0].split('/')[-1].split('.')[-2])
last_index = int(
hashed_paths[-1].split('/')[-1].split('.')[-2]) + 1
first_index = int(hashed_paths[0].split(
os.sep)[-1].split('.')[-2])
last_index = int(hashed_paths[-1].split(
os.sep)[-1].split('.')[-2]) + 1
gap = 2 * (last_index - first_index) - 1
if gap > 2 * max_interp:
cut1 = len(hashed_paths) // 3
......
......@@ -29,7 +29,7 @@ from tqdm import tqdm
from .logger import get_logger
PPGAN_HOME = os.path.expanduser("~/.cache/ppgan/")
PPGAN_HOME = os.path.expanduser(os.path.join('~', '.cache', 'ppgan'))
DOWNLOAD_RETRY_LIMIT = 3
......@@ -243,14 +243,14 @@ def _uncompress_file_tar(filepath, mode="r:*"):
def _is_a_single_file(file_list):
if len(file_list) == 1 and file_list[0].find(os.sep) < -1:
if len(file_list) == 1 and file_list[0].find('/') < -1:
return True
return False
def _is_a_single_dir(file_list):
file_name = file_list[0].split(os.sep)[0]
file_name = file_list[0].split('/')[0]
for i in range(1, len(file_list)):
if file_name != file_list[i].split(os.sep)[0]:
if file_name != file_list[i].split('/')[0]:
return False
return True
......@@ -24,14 +24,14 @@ def video2frames(video_path, outpath, **kargs):
return cmd_str
ffmpeg = ['ffmpeg ', ' -y -loglevel ', ' error ']
vid_name = video_path.split('/')[-1].split('.')[0]
vid_name = video_path.split(os.sep)[-1].split('.')[0]
out_full_path = os.path.join(outpath, vid_name)
if not os.path.exists(out_full_path):
os.makedirs(out_full_path)
# video file name
outformat = out_full_path + '/%08d.png'
outformat = os.path.join(out_full_path, '%08d.png')
cmd = ffmpeg
cmd = ffmpeg + [' -i ', video_path, ' -start_number ', ' 0 ', outformat]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册