Implementation:Junyanz Pytorch CycleGAN and pix2pix Download Pretrained Model
| Knowledge Sources | pytorch-CycleGAN-and-pix2pix |
|---|---|
| Domains | Image-to-Image Translation, Model Distribution, Transfer Learning |
| Last Updated | 2026-02-09 |
Overview
Shell scripts that download pre-trained CycleGAN and pix2pix generator checkpoints from Berkeley servers for immediate inference. These are external tool documents (shell scripts, not Python modules).
Description
Two shell scripts handle downloading pretrained models:
- scripts/download_cyclegan_model.sh -- Downloads CycleGAN pretrained generators
- scripts/download_pix2pix_model.sh -- Downloads pix2pix pretrained generators
Each script takes a model name as input, constructs the download URL, creates the target checkpoint directory, and downloads the latest_net_G.pth weights file using wget.
The checkpoint is saved to ./checkpoints/<model_name>_pretrained/latest_net_G.pth, which is the standard path expected by the model loading system when --name <model_name>_pretrained is passed during inference.
Usage
Run from the repository root directory before running test.py for inference with pretrained models.
Code Reference
Source Location
| File | Lines |
|---|---|
| scripts/download_cyclegan_model.sh | L1-11 |
| scripts/download_pix2pix_model.sh | L1-10 |
Signature
# CycleGAN pretrained model download
# Usage: bash scripts/download_cyclegan_model.sh <model_name>
FILE=$1
MODEL_DIR=./checkpoints/${FILE}_pretrained
mkdir -p $MODEL_DIR
URL="http://efrosgans.eecs.berkeley.edu/cyclegan/pretrained_models/$FILE.pth"
wget -N $URL -O $MODEL_DIR/latest_net_G.pth
# pix2pix pretrained model download
# Usage: bash scripts/download_pix2pix_model.sh <model_name>
FILE=$1
MODEL_DIR=./checkpoints/${FILE}_pretrained
mkdir -p $MODEL_DIR
URL="http://efrosgans.eecs.berkeley.edu/pix2pix/pretrained_models/$FILE.pth"
wget -N $URL -O $MODEL_DIR/latest_net_G.pth
Import
N/A -- These are shell scripts executed directly from the command line. They are not importable Python modules.
I/O Contract
| Parameter | Type | Description |
|---|---|---|
| model_name | string (CLI argument) | Name of the pretrained model to download (e.g., horse2zebra, edges2shoes) |
| Output | Type | Description |
|---|---|---|
| ./checkpoints/<model_name>_pretrained/ | directory | Checkpoint directory created for the pretrained model |
| ./checkpoints/<model_name>_pretrained/latest_net_G.pth | file | PyTorch generator weights file (state_dict) |
Usage Examples
# Download a CycleGAN pretrained model
bash scripts/download_cyclegan_model.sh horse2zebra
# Download a pix2pix pretrained model
bash scripts/download_pix2pix_model.sh edges2shoes
# Run inference with the downloaded CycleGAN model
python test.py --dataroot ./datasets/horse2zebra/testA \
--name horse2zebra_pretrained --model test --no_dropout
# Run inference with the downloaded pix2pix model
python test.py --dataroot ./datasets/edges2shoes/test \
--name edges2shoes_pretrained --model pix2pix \
--direction AtoB --dataset_mode aligned