Loading .gitignore +1 −0 Original line number Original line Diff line number Diff line __pycache__/ __pycache__/ .cache/ .cache/ training-runs/ README.md +15 −0 Original line number Original line Diff line number Diff line ## StyleGAN2-ADA on 3D-FUTURE-model textures One-liner to prepare the environment (Miniconda on Ubuntu 22.04, with a 1080Ti): ```conda create --name stylegan2 pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=11.1 -c pytorch -c conda-forge && conda activate stylegan2 && pip install click requests tqdm pyspng ninja imageio-ffmpeg==0.4.3 psutil scipy``` or create a Conda environment from `environment.yml`. Resize input images, save to .zip (~3GB, 16554 images): ```python dataset_tool.py --source=/home/user/texture-mapping/2_batch_render/data/3D-FUTURE-model --dest=3D-FUTURE-model-textures-256x256.zip --width=256 --height=256 --resize-filter=lanczos``` Start training: ```python train.py --outdir=training-runs --data=3D-FUTURE-model-textures-256x256.zip --gpus=1``` --- ## StyleGAN2-ADA — Official PyTorch implementation ## StyleGAN2-ADA — Official PyTorch implementation   Loading dataset_tool.py +28 −2 Original line number Original line Diff line number Diff line Loading @@ -49,8 +49,27 @@ def is_image_ext(fname: Union[str, Path]) -> bool: #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- exclude = set([ # list copied from batchrender_pt3d.ipynb # texture.png truncated '6934dea0-1d66-49c4-82c6-4d54d41f9707', 'f92e4a5d-691a-4555-a4e7-e09aa1dfd80e', 'e9bd517b-849a-4d61-a78d-9a05285d1b32', # the rest may not need to be excluded # CUDA out of memory '34bd8afc-dd97-3b13-8d19-3fa28f025e51', # due to 2k texture? '207129c6-8b86-3fa7-bc82-54444f33d2ff', # 1k texture? # empty model.mtl '12b1ce0f-3d2a-3211-9e05-a537e5a43e20', '530c3dbc-ae01-3b03-a52d-7d9e61fe4f7f', # UserWarning: Faces have invalid indices '7e101ef3-7722-4af8-90d5-7c562834fabd', ]) def open_image_folder(source_dir, *, max_images: Optional[int]): def open_image_folder(source_dir, *, max_images: Optional[int]): input_images = [str(f) for f in sorted(Path(source_dir).rglob('*')) if is_image_ext(f) and os.path.isfile(f)] input_images = [str(f) for f in sorted(Path(source_dir).rglob('texture.png')) if is_image_ext(f) and os.path.isfile(f)] # Load labels. # Load labels. labels = {} labels = {} Loading @@ -69,7 +88,14 @@ def open_image_folder(source_dir, *, max_images: Optional[int]): for idx, fname in enumerate(input_images): for idx, fname in enumerate(input_images): arch_fname = os.path.relpath(fname, source_dir) arch_fname = os.path.relpath(fname, source_dir) arch_fname = arch_fname.replace('\\', '/') arch_fname = arch_fname.replace('\\', '/') img = np.array(PIL.Image.open(fname)) if any(fname.find(e)>=0 for e in exclude): print(f'iterate_images: skipping {fname}') continue img = PIL.Image.open(fname) #if img.getbands() == ('R', 'G', 'B', 'A'): # print(f'iterate_images: {fname} is RGBA, converting to RGB') img = img.convert('RGB') img = np.array(img) yield dict(img=img, label=labels.get(arch_fname)) yield dict(img=img, label=labels.get(arch_fname)) if idx >= max_idx-1: if idx >= max_idx-1: break break Loading environment.yml 0 → 100644 +84 −0 Original line number Original line Diff line number Diff line name: stylegan2 channels: - pytorch - conda-forge - defaults dependencies: - _libgcc_mutex=0.1=conda_forge - _openmp_mutex=4.5=2_gnu - blas=2.16=mkl - bzip2=1.0.8=h4bc722e_7 - ca-certificates=2025.1.31=hbd8a1cb_1 - cudatoolkit=11.1.1=hb139c0e_13 - ffmpeg=4.3=hf484d3e_0 - freetype=2.12.1=h267a509_2 - giflib=5.2.2=hd590300_0 - gmp=6.3.0=hac33072_2 - gnutls=3.6.13=h85f3911_1 - intel-openmp=2025.0.0=h06a4308_1171 - jpeg=9b=h024ee3a_2 - lame=3.100=h166bdaf_1003 - lcms2=2.12=h3be6417_0 - ld_impl_linux-64=2.43=h712a8e2_4 - libblas=3.8.0=16_mkl - libcblas=3.8.0=16_mkl - libffi=3.4.6=h2dba641_1 - libgcc=14.2.0=h767d61c_2 - libgcc-ng=14.2.0=h69a702a_2 - libgfortran-ng=7.5.0=h14aa051_20 - libgfortran4=7.5.0=h14aa051_20 - libgomp=14.2.0=h767d61c_2 - libiconv=1.18=h4ce23a2_1 - liblapack=3.8.0=16_mkl - liblapacke=3.8.0=16_mkl - liblzma=5.8.1=hb9d3cd8_0 - liblzma-devel=5.8.1=hb9d3cd8_0 - libnsl=2.0.1=hd590300_0 - libpng=1.6.43=h2797004_0 - libsqlite=3.46.0=hde9e2c9_0 - libstdcxx=14.2.0=h8f9b012_2 - libstdcxx-ng=14.2.0=h4852527_2 - libtiff=4.2.0=h85742a9_0 - libuuid=2.38.1=h0b41bf4_0 - libwebp=1.2.0=h89dd481_0 - libwebp-base=1.2.0=h7f98852_2 - libxcrypt=4.4.36=hd590300_1 - libzlib=1.2.13=h4ab18f5_6 - lz4-c=1.9.3=h9c3ff4c_1 - mkl=2020.2=256 - ncurses=6.5=h2d0b736_3 - nettle=3.6=he412f7d_0 - numpy=1.22.4=py39hc58783e_0 - openh264=2.1.1=h780b84a_0 - openssl=3.5.0=h7b32b05_0 - pillow=9.3.0=py39hace64e9_1 - pip=25.0.1=pyh8b19718_0 - python=3.9.19=h0755675_0_cpython - python_abi=3.9=7_cp39 - pytorch=1.8.0=py3.9_cuda11.1_cudnn8.0.5_0 - readline=8.2=h8c095d6_2 - setuptools=79.0.1=pyhff2d567_0 - tk=8.6.13=noxft_h4845f30_101 - torchvision=0.9.0=py39_cu111 - typing_extensions=4.13.2=pyh29332c3_0 - tzdata=2025b=h78e105d_0 - wheel=0.45.1=pyhd8ed1ab_1 - xz=5.8.1=hbcc6ac9_0 - xz-gpl-tools=5.8.1=hbcc6ac9_0 - xz-tools=5.8.1=hb9d3cd8_0 - zlib=1.2.13=h4ab18f5_6 - zstd=1.4.9=ha95c52a_0 - pip: - certifi==2025.1.31 - charset-normalizer==3.4.1 - click==8.1.8 - idna==3.10 - imageio-ffmpeg==0.4.3 - ninja==1.11.1.4 - psutil==7.0.0 - pyspng==0.1.3 - requests==2.32.3 - scipy==1.13.1 - tqdm==4.67.1 - urllib3==2.4.0 prefix: /home/user/miniconda3/envs/stylegan2 Loading
.gitignore +1 −0 Original line number Original line Diff line number Diff line __pycache__/ __pycache__/ .cache/ .cache/ training-runs/
README.md +15 −0 Original line number Original line Diff line number Diff line ## StyleGAN2-ADA on 3D-FUTURE-model textures One-liner to prepare the environment (Miniconda on Ubuntu 22.04, with a 1080Ti): ```conda create --name stylegan2 pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=11.1 -c pytorch -c conda-forge && conda activate stylegan2 && pip install click requests tqdm pyspng ninja imageio-ffmpeg==0.4.3 psutil scipy``` or create a Conda environment from `environment.yml`. Resize input images, save to .zip (~3GB, 16554 images): ```python dataset_tool.py --source=/home/user/texture-mapping/2_batch_render/data/3D-FUTURE-model --dest=3D-FUTURE-model-textures-256x256.zip --width=256 --height=256 --resize-filter=lanczos``` Start training: ```python train.py --outdir=training-runs --data=3D-FUTURE-model-textures-256x256.zip --gpus=1``` --- ## StyleGAN2-ADA — Official PyTorch implementation ## StyleGAN2-ADA — Official PyTorch implementation   Loading
dataset_tool.py +28 −2 Original line number Original line Diff line number Diff line Loading @@ -49,8 +49,27 @@ def is_image_ext(fname: Union[str, Path]) -> bool: #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- exclude = set([ # list copied from batchrender_pt3d.ipynb # texture.png truncated '6934dea0-1d66-49c4-82c6-4d54d41f9707', 'f92e4a5d-691a-4555-a4e7-e09aa1dfd80e', 'e9bd517b-849a-4d61-a78d-9a05285d1b32', # the rest may not need to be excluded # CUDA out of memory '34bd8afc-dd97-3b13-8d19-3fa28f025e51', # due to 2k texture? '207129c6-8b86-3fa7-bc82-54444f33d2ff', # 1k texture? # empty model.mtl '12b1ce0f-3d2a-3211-9e05-a537e5a43e20', '530c3dbc-ae01-3b03-a52d-7d9e61fe4f7f', # UserWarning: Faces have invalid indices '7e101ef3-7722-4af8-90d5-7c562834fabd', ]) def open_image_folder(source_dir, *, max_images: Optional[int]): def open_image_folder(source_dir, *, max_images: Optional[int]): input_images = [str(f) for f in sorted(Path(source_dir).rglob('*')) if is_image_ext(f) and os.path.isfile(f)] input_images = [str(f) for f in sorted(Path(source_dir).rglob('texture.png')) if is_image_ext(f) and os.path.isfile(f)] # Load labels. # Load labels. labels = {} labels = {} Loading @@ -69,7 +88,14 @@ def open_image_folder(source_dir, *, max_images: Optional[int]): for idx, fname in enumerate(input_images): for idx, fname in enumerate(input_images): arch_fname = os.path.relpath(fname, source_dir) arch_fname = os.path.relpath(fname, source_dir) arch_fname = arch_fname.replace('\\', '/') arch_fname = arch_fname.replace('\\', '/') img = np.array(PIL.Image.open(fname)) if any(fname.find(e)>=0 for e in exclude): print(f'iterate_images: skipping {fname}') continue img = PIL.Image.open(fname) #if img.getbands() == ('R', 'G', 'B', 'A'): # print(f'iterate_images: {fname} is RGBA, converting to RGB') img = img.convert('RGB') img = np.array(img) yield dict(img=img, label=labels.get(arch_fname)) yield dict(img=img, label=labels.get(arch_fname)) if idx >= max_idx-1: if idx >= max_idx-1: break break Loading
environment.yml 0 → 100644 +84 −0 Original line number Original line Diff line number Diff line name: stylegan2 channels: - pytorch - conda-forge - defaults dependencies: - _libgcc_mutex=0.1=conda_forge - _openmp_mutex=4.5=2_gnu - blas=2.16=mkl - bzip2=1.0.8=h4bc722e_7 - ca-certificates=2025.1.31=hbd8a1cb_1 - cudatoolkit=11.1.1=hb139c0e_13 - ffmpeg=4.3=hf484d3e_0 - freetype=2.12.1=h267a509_2 - giflib=5.2.2=hd590300_0 - gmp=6.3.0=hac33072_2 - gnutls=3.6.13=h85f3911_1 - intel-openmp=2025.0.0=h06a4308_1171 - jpeg=9b=h024ee3a_2 - lame=3.100=h166bdaf_1003 - lcms2=2.12=h3be6417_0 - ld_impl_linux-64=2.43=h712a8e2_4 - libblas=3.8.0=16_mkl - libcblas=3.8.0=16_mkl - libffi=3.4.6=h2dba641_1 - libgcc=14.2.0=h767d61c_2 - libgcc-ng=14.2.0=h69a702a_2 - libgfortran-ng=7.5.0=h14aa051_20 - libgfortran4=7.5.0=h14aa051_20 - libgomp=14.2.0=h767d61c_2 - libiconv=1.18=h4ce23a2_1 - liblapack=3.8.0=16_mkl - liblapacke=3.8.0=16_mkl - liblzma=5.8.1=hb9d3cd8_0 - liblzma-devel=5.8.1=hb9d3cd8_0 - libnsl=2.0.1=hd590300_0 - libpng=1.6.43=h2797004_0 - libsqlite=3.46.0=hde9e2c9_0 - libstdcxx=14.2.0=h8f9b012_2 - libstdcxx-ng=14.2.0=h4852527_2 - libtiff=4.2.0=h85742a9_0 - libuuid=2.38.1=h0b41bf4_0 - libwebp=1.2.0=h89dd481_0 - libwebp-base=1.2.0=h7f98852_2 - libxcrypt=4.4.36=hd590300_1 - libzlib=1.2.13=h4ab18f5_6 - lz4-c=1.9.3=h9c3ff4c_1 - mkl=2020.2=256 - ncurses=6.5=h2d0b736_3 - nettle=3.6=he412f7d_0 - numpy=1.22.4=py39hc58783e_0 - openh264=2.1.1=h780b84a_0 - openssl=3.5.0=h7b32b05_0 - pillow=9.3.0=py39hace64e9_1 - pip=25.0.1=pyh8b19718_0 - python=3.9.19=h0755675_0_cpython - python_abi=3.9=7_cp39 - pytorch=1.8.0=py3.9_cuda11.1_cudnn8.0.5_0 - readline=8.2=h8c095d6_2 - setuptools=79.0.1=pyhff2d567_0 - tk=8.6.13=noxft_h4845f30_101 - torchvision=0.9.0=py39_cu111 - typing_extensions=4.13.2=pyh29332c3_0 - tzdata=2025b=h78e105d_0 - wheel=0.45.1=pyhd8ed1ab_1 - xz=5.8.1=hbcc6ac9_0 - xz-gpl-tools=5.8.1=hbcc6ac9_0 - xz-tools=5.8.1=hb9d3cd8_0 - zlib=1.2.13=h4ab18f5_6 - zstd=1.4.9=ha95c52a_0 - pip: - certifi==2025.1.31 - charset-normalizer==3.4.1 - click==8.1.8 - idna==3.10 - imageio-ffmpeg==0.4.3 - ninja==1.11.1.4 - psutil==7.0.0 - pyspng==0.1.3 - requests==2.32.3 - scipy==1.13.1 - tqdm==4.67.1 - urllib3==2.4.0 prefix: /home/user/miniconda3/envs/stylegan2