Causal3D_Dataset / zip_scene.py
LLDDSS's picture
Upload folder using huggingface_hub
ba00758 verified
raw
history blame
1.11 kB
import os
import zipfile
from pathlib import Path
def zip_folder(folder_path, output_path):
"""
压缩单个文件夹
"""
folder = Path(folder_path)
with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
for file in folder.rglob('*'):
zipf.write(file, file.relative_to(folder.parent))
print(f"✅ Zipped {folder} -> {output_path}")
def zip_all_scenes(root_dir):
"""
扫描 Real, Hypothetical, Multi_View 文件夹,自动打包每个 scene
"""
root = Path(root_dir)
categories = ["Real", "Hypothetical", "Multi_View"]
for category in categories:
category_path = root / category
if not category_path.exists():
print(f"⚠️ Skip {category}: not found")
continue
for scene in category_path.iterdir():
if scene.is_dir():
output_zip = root / f"{category}_{scene.name}.zip"
zip_folder(scene, output_zip)
if __name__ == "__main__":
# 修改为你的根目录
zip_all_scenes(".")
print("✅ All scenes zipped successfully.")