Skip to content

Commit

Permalink
update eval script
Browse files Browse the repository at this point in the history
  • Loading branch information
wtomin committed Feb 11, 2025
1 parent 15f06c2 commit 4a88ab9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 25 deletions.
6 changes: 3 additions & 3 deletions examples/hunyuanvideo/hyvideo/utils/dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __init__(
real_data_file_path=None,
sample_rate=1,
crop_size=None,
short_size=128,
size=128,
output_columns=["real", "generated"],
) -> None:
super().__init__()
Expand All @@ -179,12 +179,12 @@ def __init__(
self.num_frames = num_frames
self.sample_rate = sample_rate
self.crop_size = crop_size
self.short_size = short_size
self.size = size
self.output_columns = output_columns
self.real_video_dir = real_video_dir

self.pixel_transforms = create_video_transforms(
size=self.short_size,
size=self.size,
crop_size=crop_size,
random_crop=False,
disable_flip=True,
Expand Down
24 changes: 5 additions & 19 deletions examples/hunyuanvideo/scripts/eval/eval_common_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@
sys.path.insert(0, mindone_lib_path)
sys.path.append(".")

from cal_lpips import calculate_lpips
from cal_psnr import calculate_psnr
from hyvideo.utils.dataset_utils import VideoPairDataset, create_dataloader

from .cal_lpips import calculate_lpips
from .cal_psnr import calculate_psnr

flolpips_isavailable = False
calculate_flolpips = None
from hyvideo.eval.cal_ssim import calculate_ssim
from cal_ssim import calculate_ssim
from tqdm import tqdm


Expand Down Expand Up @@ -109,15 +108,7 @@ def main():
help="Number of processes to use for data loading. Defaults to `min(8, num_cpus)`",
)
parser.add_argument("--sample-fps", type=int, default=30, help="Sampling frames per second for the video.")
parser.add_argument(
"--short-size",
type=int,
default=256,
help=(
"Resize the video frames to this size. If provided, the smaller dimension will be resized to this value "
"while maintaining the aspect ratio. "
),
)

parser.add_argument(
"--height",
type=int,
Expand Down Expand Up @@ -150,11 +141,6 @@ def main():
)

args = parser.parse_args()
# Check if short_size is less than the minimum of height and width
if args.short_size < min(args.height, args.width):
raise ValueError(
f"short_size ({args.short_size}) cannot be less than the minimum of height ({args.height}) and width ({args.width})."
)

if args.num_workers is None:
try:
Expand All @@ -176,7 +162,7 @@ def main():
real_data_file_path=args.real_data_file_path,
sample_rate=args.sample_rate,
crop_size=(args.height, args.width),
short_size=args.short_size,
size=(args.height, args.width),
)

dataloader = create_dataloader(
Expand Down
1 change: 0 additions & 1 deletion examples/hunyuanvideo/scripts/eval/script/cal_lpips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ python scripts/eval/eval_common_metrics.py \
--num-frames 33 \
--height 360 \
--width 640 \
--short-size 360 \
--device 'Ascend' \
--metric 'lpips'
1 change: 0 additions & 1 deletion examples/hunyuanvideo/scripts/eval/script/cal_psnr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ python scripts/eval/eval_common_metrics.py \
--num-frames 33 \
--height 360 \
--width 640 \
--short-size 360 \
--device 'Ascend' \
--metric 'psnr'
1 change: 0 additions & 1 deletion examples/hunyuanvideo/scripts/eval/script/cal_ssim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ python scripts/eval/eval_common_metrics.py \
--num-frames 33 \
--height 360 \
--width 640 \
--short-size 360 \
--device 'Ascend' \
--metric 'ssim'

0 comments on commit 4a88ab9

Please sign in to comment.