[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9708":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":36,"readmeContent":37,"aiSummary":38,"trendingCount":16,"starSnapshotCount":16,"syncStatus":39,"lastSyncTime":40,"discoverSource":41},9708,"pix2pix","phillipi\u002Fpix2pix","phillipi","Image-to-image translation with conditional adversarial nets","https:\u002F\u002Fphillipi.github.io\u002Fpix2pix\u002F",null,"Lua",10641,1733,310,90,0,1,3,14,4,74.62,"Other",false,"master",true,[27,28,29,30,31,32,33,34,35,5],"computer-graphics","computer-vision","dcgan","deep-learning","gan","generative-adversarial-network","image-generation","image-manipulation","image-to-image-translation","2026-06-12 04:00:46","\n# pix2pix\n[Project](https:\u002F\u002Fphillipi.github.io\u002Fpix2pix\u002F) | [Arxiv](https:\u002F\u002Farxiv.org\u002Fabs\u002F1611.07004) |\n[PyTorch](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix)\n\nTorch implementation for learning a mapping from input images to output images, for example:\n\n\u003Cimg src=\"imgs\u002Fexamples.jpg\" width=\"900px\"\u002F>\n\nImage-to-Image Translation with Conditional Adversarial Networks  \n [Phillip Isola](http:\u002F\u002Fweb.mit.edu\u002Fphillipi\u002F), [Jun-Yan Zhu](https:\u002F\u002Fwww.cs.cmu.edu\u002F~junyanz\u002F), [Tinghui Zhou](https:\u002F\u002Fpeople.eecs.berkeley.edu\u002F~tinghuiz\u002F), [Alexei A. Efros](https:\u002F\u002Fpeople.eecs.berkeley.edu\u002F~efros\u002F)   \n CVPR, 2017.\n\nOn some tasks, decent results can be obtained fairly quickly and on small datasets. For example, to learn to generate facades (example shown above), we trained on just 400 images for about 2 hours (on a single Pascal Titan X GPU). However, for harder problems it may be important to train on far larger datasets, and for many hours or even days.\n\n**Note**: Please check out our [PyTorch](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix) implementation for pix2pix and CycleGAN. The PyTorch version is under active development and can produce results comparable to or better than this Torch version.\n\n## Setup\n\n### Prerequisites\n- Linux or OSX\n- NVIDIA GPU + CUDA CuDNN (CPU mode and CUDA without CuDNN may work with minimal modification, but untested)\n\n### Getting Started\n- Install torch and dependencies from https:\u002F\u002Fgithub.com\u002Ftorch\u002Fdistro\n- Install torch packages `nngraph` and `display`\n```bash\nluarocks install nngraph\nluarocks install https:\u002F\u002Fraw.githubusercontent.com\u002Fszym\u002Fdisplay\u002Fmaster\u002Fdisplay-scm-0.rockspec\n```\n- Clone this repo:\n```bash\ngit clone git@github.com:phillipi\u002Fpix2pix.git\ncd pix2pix\n```\n- Download the dataset (e.g., [CMP Facades](http:\u002F\u002Fcmp.felk.cvut.cz\u002F~tylecr1\u002Ffacade\u002F)):\n```bash\nbash .\u002Fdatasets\u002Fdownload_dataset.sh facades\n```\n- Train the model\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Ffacades name=facades_generation which_direction=BtoA th train.lua\n```\n- (CPU only) The same training command without using a GPU or CUDNN. Setting the environment variables ```gpu=0 cudnn=0``` forces CPU only\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Ffacades name=facades_generation which_direction=BtoA gpu=0 cudnn=0 batchSize=10 save_epoch_freq=5 th train.lua\n```\n- (Optionally) start the display server to view results as the model trains. ( See [Display UI](#display-ui) for more details):\n```bash\nth -ldisplay.start 8000 0.0.0.0\n```\n\n- Finally, test the model:\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Ffacades name=facades_generation which_direction=BtoA phase=val th test.lua\n```\nThe test results will be saved to an html file here: `.\u002Fresults\u002Ffacades_generation\u002Flatest_net_G_val\u002Findex.html`.\n\n## Train\n```bash\nDATA_ROOT=\u002Fpath\u002Fto\u002Fdata\u002F name=expt_name which_direction=AtoB th train.lua\n```\nSwitch `AtoB` to `BtoA` to train translation in opposite direction.\n\nModels are saved to `.\u002Fcheckpoints\u002Fexpt_name` (can be changed by passing `checkpoint_dir=your_dir` in train.lua).\n\nSee `opt` in train.lua for additional training options.\n\n## Test\n```bash\nDATA_ROOT=\u002Fpath\u002Fto\u002Fdata\u002F name=expt_name which_direction=AtoB phase=val th test.lua\n```\n\nThis will run the model named `expt_name` in direction `AtoB` on all images in `\u002Fpath\u002Fto\u002Fdata\u002Fval`.\n\nResult images, and a webpage to view them, are saved to `.\u002Fresults\u002Fexpt_name` (can be changed by passing `results_dir=your_dir` in test.lua).\n\nSee `opt` in test.lua for additional testing options.\n\n\n## Datasets\nDownload the datasets using the following script. Some of the datasets are collected by other researchers. Please cite their papers if you use the data.\n```bash\nbash .\u002Fdatasets\u002Fdownload_dataset.sh dataset_name\n```\n- `facades`: 400 images from [CMP Facades dataset](http:\u002F\u002Fcmp.felk.cvut.cz\u002F~tylecr1\u002Ffacade\u002F). [[Citation](datasets\u002Fbibtex\u002Ffacades.tex)]\n- `cityscapes`: 2975 images from the [Cityscapes training set](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F).  [[Citation](datasets\u002Fbibtex\u002Fcityscapes.tex)]\n- `maps`: 1096 training images scraped from Google Maps\n- `edges2shoes`: 50k training images from [UT Zappos50K dataset](http:\u002F\u002Fvision.cs.utexas.edu\u002Fprojects\u002Ffinegrained\u002Futzap50k\u002F). Edges are computed by [HED](https:\u002F\u002Fgithub.com\u002Fs9xie\u002Fhed) edge detector + post-processing.\n[[Citation](datasets\u002Fbibtex\u002Fshoes.tex)]\n- `edges2handbags`: 137K Amazon Handbag images from [iGAN project](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FiGAN). Edges are computed by [HED](https:\u002F\u002Fgithub.com\u002Fs9xie\u002Fhed) edge detector + post-processing. [[Citation](datasets\u002Fbibtex\u002Fhandbags.tex)]\n- `night2day`: around 20K natural scene images from  [Transient Attributes dataset](http:\u002F\u002Ftransattr.cs.brown.edu\u002F) [[Citation](datasets\u002Fbibtex\u002Ftransattr.tex)]. To train a `day2night` pix2pix model, you need to add `which_direction=BtoA`.\n\n## Models\nDownload the pre-trained models with the following script. You need to rename the model (e.g., `facades_label2image` to `\u002Fcheckpoints\u002Ffacades\u002Flatest_net_G.t7`) after the download has finished.\n```bash\nbash .\u002Fmodels\u002Fdownload_model.sh model_name\n```\n- `facades_label2image` (label -> facade): trained on the CMP Facades dataset.\n- `cityscapes_label2image` (label -> street scene): trained on the Cityscapes dataset.\n- `cityscapes_image2label` (street scene -> label): trained on the Cityscapes dataset.\n- `edges2shoes` (edge -> photo): trained on UT Zappos50K dataset.\n- `edges2handbags` (edge -> photo): trained on Amazon handbags images.\n- `day2night` (daytime scene -> nighttime scene): trained on around 100 [webcams](http:\u002F\u002Ftransattr.cs.brown.edu\u002F).\n\n## Setup Training and Test data\n### Generating Pairs\nWe provide a python script to generate training data in the form of pairs of images {A,B}, where A and B are two different depictions of the same underlying scene. For example, these might be pairs {label map, photo} or {bw image, color image}. Then we can learn to translate A to B or B to A:\n\nCreate folder `\u002Fpath\u002Fto\u002Fdata` with subfolders `A` and `B`. `A` and `B` should each have their own subfolders `train`, `val`, `test`, etc. In `\u002Fpath\u002Fto\u002Fdata\u002FA\u002Ftrain`, put training images in style A. In `\u002Fpath\u002Fto\u002Fdata\u002FB\u002Ftrain`, put the corresponding images in style B. Repeat same for other data splits (`val`, `test`, etc).\n\nCorresponding images in a pair {A,B} must be the same size and have the same filename, e.g., `\u002Fpath\u002Fto\u002Fdata\u002FA\u002Ftrain\u002F1.jpg` is considered to correspond to `\u002Fpath\u002Fto\u002Fdata\u002FB\u002Ftrain\u002F1.jpg`.\n\nOnce the data is formatted this way, call:\n```bash\npython scripts\u002Fcombine_A_and_B.py --fold_A \u002Fpath\u002Fto\u002Fdata\u002FA --fold_B \u002Fpath\u002Fto\u002Fdata\u002FB --fold_AB \u002Fpath\u002Fto\u002Fdata\n```\n\nThis will combine each pair of images (A,B) into a single image file, ready for training.\n\n### Notes on Colorization\nNo need to run `combine_A_and_B.py` for colorization. Instead, you need to prepare some natural images and set `preprocess=colorization` in the script. The program will automatically convert each RGB image into Lab color space, and create  `L -> ab` image pair during the training. Also set `input_nc=1` and `output_nc=2`.\n\n### Extracting Edges\nWe provide python and Matlab scripts to extract coarse edges from photos. Run `scripts\u002Fedges\u002Fbatch_hed.py` to compute [HED](https:\u002F\u002Fgithub.com\u002Fs9xie\u002Fhed) edges. Run `scripts\u002Fedges\u002FPostprocessHED.m` to simplify edges with additional post-processing steps. Check the code documentation for more details.\n\n### Evaluating Labels2Photos on Cityscapes\nWe provide scripts for running the evaluation of the Labels2Photos task on the Cityscapes **validation** set. We assume that you have installed `caffe` (and `pycaffe`) in your system. If not, see the [official website](http:\u002F\u002Fcaffe.berkeleyvision.org\u002Finstallation.html) for installation instructions. Once `caffe` is successfully installed, download the pre-trained FCN-8s semantic segmentation model (512MB) by running\n```bash\nbash .\u002Fscripts\u002Feval_cityscapes\u002Fdownload_fcn8s.sh\n```\nThen make sure `.\u002Fscripts\u002Feval_cityscapes\u002F` is in your system's python path. If not, run the following command to add it\n```bash\nexport PYTHONPATH=${PYTHONPATH}:.\u002Fscripts\u002Feval_cityscapes\u002F\n```\nNow you can run the following command to evaluate your predictions:\n```bash\npython .\u002Fscripts\u002Feval_cityscapes\u002Fevaluate.py --cityscapes_dir \u002Fpath\u002Fto\u002Foriginal\u002Fcityscapes\u002Fdataset\u002F --result_dir \u002Fpath\u002Fto\u002Fyour\u002Fpredictions\u002F --output_dir \u002Fpath\u002Fto\u002Foutput\u002Fdirectory\u002F\n```\nImages stored under `--result_dir` should contain your model predictions on the Cityscapes **validation** split, and have the original Cityscapes naming convention (e.g., `frankfurt_000001_038418_leftImg8bit.png`). The script will output a text file under `--output_dir` containing the metric.\n\n**Further notes**: Our pre-trained FCN model is **not** supposed to work on Cityscapes in the original resolution (1024x2048) as it was trained on 256x256 images that are then upsampled to 1024x2048 during training. The purpose of the resizing during training was to 1) keep the label maps in the original high resolution untouched and 2) avoid the need to change the standard FCN training code and the architecture for Cityscapes. During test time, you need to synthesize 256x256 results. Our test code will automatically upsample your results to 1024x2048 before feeding them to the pre-trained FCN model. The output is at 1024x2048 resolution and will be compared to 1024x2048 ground truth labels. You do not need to resize the ground truth labels. The best way to verify whether everything is correct is to reproduce the numbers for real images in the paper first. To achieve it, you need to resize the original\u002Freal Cityscapes images (**not** labels) to 256x256 and feed them to the evaluation code.\n\n\n## Display UI\nOptionally, for displaying images during training and test, use the [display package](https:\u002F\u002Fgithub.com\u002Fszym\u002Fdisplay).\n\n- Install it with: `luarocks install https:\u002F\u002Fraw.githubusercontent.com\u002Fszym\u002Fdisplay\u002Fmaster\u002Fdisplay-scm-0.rockspec`\n- Then start the server with: `th -ldisplay.start`\n- Open this URL in your browser: [http:\u002F\u002Flocalhost:8000](http:\u002F\u002Flocalhost:8000)\n\nBy default, the server listens on localhost. Pass `0.0.0.0` to allow external connections on any interface:\n```bash\nth -ldisplay.start 8000 0.0.0.0\n```\nThen open `http:\u002F\u002F(hostname):(port)\u002F` in your browser to load the remote desktop.\n\nL1 error is plotted to the display by default. Set the environment variable `display_plot` to a comma-separated list of values `errL1`, `errG` and `errD` to visualize the L1, generator, and discriminator error respectively. For example, to plot only the generator and discriminator errors to the display instead of the default L1 error, set `display_plot=\"errG,errD\"`.\n\n## Citation\nIf you use this code for your research, please cite our paper \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fpdf\u002F1611.07004v1.pdf\">Image-to-Image Translation Using Conditional Adversarial Networks\u003C\u002Fa>:\n\n```\n@article{pix2pix2017,\n  title={Image-to-Image Translation with Conditional Adversarial Networks},\n  author={Isola, Phillip and Zhu, Jun-Yan and Zhou, Tinghui and Efros, Alexei A},\n  journal={CVPR},\n  year={2017}\n}\n```\n\n## Cat Paper Collection\nIf you love cats, and love reading cool graphics, vision, and learning papers, please check out the Cat Paper Collection:  \n[[Github]](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCatPapers) [[Webpage]](https:\u002F\u002Fwww.cs.cmu.edu\u002F~junyanz\u002Fcat\u002Fcat_papers.html)\n\n## Acknowledgments\nCode borrows heavily from [DCGAN](https:\u002F\u002Fgithub.com\u002Fsoumith\u002Fdcgan.torch). The data loader is modified from [DCGAN](https:\u002F\u002Fgithub.com\u002Fsoumith\u002Fdcgan.torch) and  [Context-Encoder](https:\u002F\u002Fgithub.com\u002Fpathak22\u002Fcontext-encoder).\n","pix2pix 是一个用于图像到图像转换的项目，基于条件对抗网络实现。它利用深度学习技术特别是生成对抗网络（GAN）来学习从输入图像到输出图像的映射，适用于如将草图转换为照片、黑白图像上色等多种图像处理任务。该项目使用 Lua 语言编写，支持在配备 NVIDIA GPU 和 CUDA CuDNN 的 Linux 或 OSX 系统上运行。尽管官方推荐转向其更活跃维护的 PyTorch 版本以获得更好的性能与结果，但原始 Torch 实现仍然提供了快速入门图像转换任务的能力，并且在某些场景下仅需少量数据即可得到不错的效果。对于需要高效地进行特定类型图像转换的研究者或开发者来说，pix2pix 是一个非常实用的选择。",2,"2026-06-11 03:24:21","top_topic"]