mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-24 13:09:43 +00:00
chore(format): formatting code
This commit is contained in:
@@ -26,7 +26,7 @@ This module provides utilities for:
|
|||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed, ProcessPoolExecutor
|
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import datasets
|
import datasets
|
||||||
@@ -1933,9 +1933,7 @@ def reencode_dataset(
|
|||||||
return dataset
|
return dataset
|
||||||
logging.info(f"Re-encoding {len(video_paths_list)} video file(s) with {camera_encoder}")
|
logging.info(f"Re-encoding {len(video_paths_list)} video file(s) with {camera_encoder}")
|
||||||
|
|
||||||
worker_args = [
|
worker_args = [(vp, camera_encoder, encoder_threads) for vp in video_paths_list]
|
||||||
(vp, camera_encoder, encoder_threads) for vp in video_paths_list
|
|
||||||
]
|
|
||||||
if num_workers and num_workers >= 1:
|
if num_workers and num_workers >= 1:
|
||||||
with ProcessPoolExecutor(max_workers=num_workers) as pool:
|
with ProcessPoolExecutor(max_workers=num_workers) as pool:
|
||||||
futures = [pool.submit(_reencode_video_worker, args) for args in worker_args]
|
futures = [pool.submit(_reencode_video_worker, args) for args in worker_args]
|
||||||
@@ -1952,9 +1950,7 @@ def reencode_dataset(
|
|||||||
# Refresh video info in metadata for every video key.
|
# Refresh video info in metadata for every video key.
|
||||||
for vid_key in meta.video_keys:
|
for vid_key in meta.video_keys:
|
||||||
video_path = meta.root / meta.get_video_file_path(0, vid_key)
|
video_path = meta.root / meta.get_video_file_path(0, vid_key)
|
||||||
meta.info.features[vid_key]["info"] = get_video_info(
|
meta.info.features[vid_key]["info"] = get_video_info(video_path, camera_encoder=camera_encoder)
|
||||||
video_path, camera_encoder=camera_encoder
|
|
||||||
)
|
|
||||||
|
|
||||||
write_info(meta.info, meta.root)
|
write_info(meta.info, meta.root)
|
||||||
logging.info("Dataset metadata updated.")
|
logging.info("Dataset metadata updated.")
|
||||||
|
|||||||
@@ -456,7 +456,9 @@ def reencode_video(
|
|||||||
with av.open(
|
with av.open(
|
||||||
tmp_output_video_path,
|
tmp_output_video_path,
|
||||||
mode="w",
|
mode="w",
|
||||||
options={"movflags": "faststart"}, # faststart is to move the metadata to the beginning of the file to speed up loading
|
options={
|
||||||
|
"movflags": "faststart"
|
||||||
|
}, # faststart is to move the metadata to the beginning of the file to speed up loading
|
||||||
) as dst:
|
) as dst:
|
||||||
out_stream = dst.add_stream(vcodec, fps, options=video_options)
|
out_stream = dst.add_stream(vcodec, fps, options=video_options)
|
||||||
out_stream.pix_fmt = pix_fmt
|
out_stream.pix_fmt = pix_fmt
|
||||||
|
|||||||
@@ -673,8 +673,7 @@ def handle_reencode_videos(cfg: EditDatasetConfig) -> None:
|
|||||||
current_encoder = VideoEncoderConfig.from_video_info(current_info)
|
current_encoder = VideoEncoderConfig.from_video_info(current_info)
|
||||||
if current_encoder == cfg.operation.camera_encoder:
|
if current_encoder == cfg.operation.camera_encoder:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Videos in {cfg.repo_id} are already encoded with {current_encoder}. "
|
f"Videos in {cfg.repo_id} are already encoded with {current_encoder}. Nothing to do."
|
||||||
"Nothing to do."
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
"""Unit tests for ``lerobot.datasets.video_utils`` encoding functions and ``lerobot.configs.video.VideoEncoderConfig`` config class."""
|
"""Unit tests for ``lerobot.datasets.video_utils`` encoding functions and ``lerobot.configs.video.VideoEncoderConfig`` config class."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import shutil
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -499,6 +498,7 @@ class TestReencodeVideo:
|
|||||||
assert info["video.g"] == 6
|
assert info["video.g"] == 6
|
||||||
assert info["video.crf"] == 23
|
assert info["video.crf"] == 23
|
||||||
|
|
||||||
|
|
||||||
class TestConcatenateVideoFiles:
|
class TestConcatenateVideoFiles:
|
||||||
def test_two_clips_frame_count(self, tmp_path):
|
def test_two_clips_frame_count(self, tmp_path):
|
||||||
"""Output frame count equals the sum of the two input frame counts."""
|
"""Output frame count equals the sum of the two input frame counts."""
|
||||||
|
|||||||
Reference in New Issue
Block a user