[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-junyanz--CycleGAN":3,"tool-junyanz--CycleGAN":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":81,"owner_email":82,"owner_twitter":83,"owner_website":84,"owner_url":85,"languages":86,"stars":103,"forks":104,"last_commit_at":105,"license":106,"difficulty_score":107,"env_os":108,"env_gpu":109,"env_ram":110,"env_deps":111,"category_tags":121,"github_topics":122,"view_count":23,"oss_zip_url":82,"oss_zip_packed_at":82,"status":16,"created_at":134,"updated_at":135,"faqs":136,"releases":170},3773,"junyanz\u002FCycleGAN","CycleGAN","Software that can generate photos from paintings,  turn horses into zebras,  perform style transfer, and more.","CycleGAN 是一款强大的图像转换工具，能够无需成对训练数据即可实现不同风格图像间的相互转化。它能将照片变成莫奈风格的画作，把马匹转换为斑马，甚至完成季节变换或照片增强等任务。\n\n传统图像转换方法通常依赖大量“输入 - 输出”配对数据（如某地的夏天照片和对应冬天照片），这在现实中很难获取。CycleGAN 巧妙解决了这一难题，它利用“循环一致性损失”机制，仅凭两组无关联的图片集合（如一堆马的照片和一堆斑马的照片）就能学习两者间的映射关系，大大降低了数据准备门槛。\n\n这款工具特别适合计算机视觉研究人员、AI 开发者以及数字艺术家使用。研究人员可借此探索无监督学习的前沿算法；开发者能将其集成到图像处理应用中；设计师和艺术家则能快速创作出风格独特的视觉作品。虽然普通用户也可通过封装好的应用体验其功能，但直接使用源码仍需一定的编程基础。\n\nCycleGAN 的核心亮点在于其创新的“循环一致对抗网络”架构。它通过两个生成器和两个判别器的博弈，确保图像在转换后还能还原回原始状态，从而保证转换结果的真实性和合理性。作为 2017 年 ICCV 会议的杰出成果，它不仅开源了代码，还推动了后续众多改","CycleGAN 是一款强大的图像转换工具，能够无需成对训练数据即可实现不同风格图像间的相互转化。它能将照片变成莫奈风格的画作，把马匹转换为斑马，甚至完成季节变换或照片增强等任务。\n\n传统图像转换方法通常依赖大量“输入 - 输出”配对数据（如某地的夏天照片和对应冬天照片），这在现实中很难获取。CycleGAN 巧妙解决了这一难题，它利用“循环一致性损失”机制，仅凭两组无关联的图片集合（如一堆马的照片和一堆斑马的照片）就能学习两者间的映射关系，大大降低了数据准备门槛。\n\n这款工具特别适合计算机视觉研究人员、AI 开发者以及数字艺术家使用。研究人员可借此探索无监督学习的前沿算法；开发者能将其集成到图像处理应用中；设计师和艺术家则能快速创作出风格独特的视觉作品。虽然普通用户也可通过封装好的应用体验其功能，但直接使用源码仍需一定的编程基础。\n\nCycleGAN 的核心亮点在于其创新的“循环一致对抗网络”架构。它通过两个生成器和两个判别器的博弈，确保图像在转换后还能还原回原始状态，从而保证转换结果的真实性和合理性。作为 2017 年 ICCV 会议的杰出成果，它不仅开源了代码，还推动了后续众多改进模型（如 CUT）的发展，是图像风格迁移领域里程碑式的存在。","\u003Cimg src='https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_7567749554db.gif' align=\"right\" width=384>\n\n\u003Cbr>\u003Cbr>\u003Cbr>\n\n# CycleGAN\n### [PyTorch](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix) | [project page](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F) |   [paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1703.10593.pdf)\n\nTorch implementation for learning an image-to-image translation (i.e. [pix2pix](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix)) **without** input-output pairs, for example:\n\n**New**:  Please check out [contrastive-unpaired-translation](https:\u002F\u002Fgithub.com\u002Ftaesungp\u002Fcontrastive-unpaired-translation) (CUT), our new unpaired image-to-image translation model that enables fast and memory-efficient training.\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_9ca7bf930668.jpg\" width=\"1000px\"\u002F>\n\n[Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F)  \n [Jun-Yan Zhu](https:\u002F\u002Fpeople.eecs.berkeley.edu\u002F~junyanz\u002F)\\*,  [Taesung Park](https:\u002F\u002Ftaesung.me\u002F)\\*, [Phillip Isola](http:\u002F\u002Fweb.mit.edu\u002Fphillipi\u002F), [Alexei A. Efros](https:\u002F\u002Fpeople.eecs.berkeley.edu\u002F~efros\u002F)  \n Berkeley AI Research Lab, UC Berkeley  \n In ICCV 2017. (* equal contributions)  \n\nThis package includes CycleGAN, [pix2pix](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix), as well as other methods like [BiGAN](https:\u002F\u002Farxiv.org\u002Fabs\u002F1605.09782)\u002F[ALI](https:\u002F\u002Fishmaelbelghazi.github.io\u002FALI\u002F) and Apple's paper [S+U learning](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1612.07828.pdf).  \nThe code was written by [Jun-Yan Zhu](https:\u002F\u002Fgithub.com\u002Fjunyanz) and [Taesung Park](https:\u002F\u002Fgithub.com\u002Ftaesung).  \n**Update**: Please check out [PyTorch](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix) implementation for CycleGAN and pix2pix.\nThe PyTorch version is under active development and can produce results comparable or better than this Torch version.\n\n## Other implementations:\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fleehomyc\u002Fcyclegan-1\"> [Tensorflow]\u003C\u002Fa> (by Harry Yang),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Farchitrathore\u002FCycleGAN\u002F\">[Tensorflow]\u003C\u002Fa> (by Archit Rathore),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fvanhuyz\u002FCycleGAN-TensorFlow\">[Tensorflow]\u003C\u002Fa> (by Van Huy),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FXHUJOY\u002FCycleGAN-tensorflow\">[Tensorflow]\u003C\u002Fa> (by Xiaowei Hu),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FLynnHo\u002FCycleGAN-Tensorflow-Simple\"> [Tensorflow-simple]\u003C\u002Fa> (by Zhenliang He),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fluoxier\u002FCycleGAN_Tensorlayer\"> [TensorLayer]\u003C\u002Fa> (by luoxier),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FAixile\u002Fchainer-cyclegan\">[Chainer]\u003C\u002Fa> (by Yanghua Jin),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fyunjey\u002Fmnist-svhn-transfer\">[Minimal PyTorch]\u003C\u002Fa> (by yunjey),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FLdpe2G\u002FDeepLearningForFun\u002Ftree\u002Fmaster\u002FMxnet-Scala\u002FCycleGAN\">[Mxnet]\u003C\u002Fa> (by Ldpe2G),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Ftjwei\u002FGANotebooks\">[lasagne\u002FKeras]\u003C\u002Fa> (by tjwei),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fsimontomaskarlsson\u002FCycleGAN-Keras\">[Keras]\u003C\u002Fa> (by Simon Karlsson)\u003C\u002Fp>\n\u003C\u002Ful>\n\n## Applications\n### Monet Paintings to Photos\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_ef2a3a8bac9b.jpg\" width=\"1000px\"\u002F>\n\n### Collection Style Transfer\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_4d78b4c2906f.jpg\" width=\"1000px\"\u002F>\n\n### Object Transfiguration\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_fb0d72ed12b8.jpg\" width=\"1000px\"\u002F>\n\n### Season Transfer\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_1196c5c8aed2.jpg\" width=\"1000px\"\u002F>\n\n### Photo Enhancement: Narrow depth of field\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_377c9c38c004.jpg\" width=\"1000px\"\u002F>\n\n\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- For MAC users, you need the Linux\u002FGNU commands `gfind` and `gwc`, which can be installed with `brew install findutils coreutils`.\n\n## Getting Started\n### Installation\n- Install torch and dependencies from https:\u002F\u002Fgithub.com\u002Ftorch\u002Fdistro\n- Install torch packages `nngraph`, `class`, `display`\n```bash\nluarocks install nngraph\nluarocks install class\nluarocks install https:\u002F\u002Fraw.githubusercontent.com\u002Fszym\u002Fdisplay\u002Fmaster\u002Fdisplay-scm-0.rockspec\n```\n- Clone this repo:\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\ncd CycleGAN\n```\n\n### Apply a Pre-trained Model\n- Download the test photos (taken by [Alexei Efros](https:\u002F\u002Fwww.flickr.com\u002Fphotos\u002Faaefros)):\n```\nbash .\u002Fdatasets\u002Fdownload_dataset.sh ae_photos\n```\n- Download the pre-trained model `style_cezanne` (For CPU model, use `style_cezanne_cpu`):\n```\nbash .\u002Fpretrained_models\u002Fdownload_model.sh style_cezanne\n```\n- Now, let's generate Paul Cézanne style images:\n```\nDATA_ROOT=.\u002Fdatasets\u002Fae_photos name=style_cezanne_pretrained model=one_direction_test phase=test loadSize=256 fineSize=256 resize_or_crop=\"scale_width\" th test.lua\n```\nThe test results will be saved to `.\u002Fresults\u002Fstyle_cezanne_pretrained\u002Flatest_test\u002Findex.html`.  \nPlease refer to [Model Zoo](#model-zoo) for more pre-trained models.\n`.\u002Fexamples\u002Ftest_vangogh_style_on_ae_photos.sh` is an example script that downloads the pretrained Van Gogh style network and runs it on Efros's photos.\n\n### Train\n- Download a dataset (e.g. zebra and horse images from ImageNet):\n```bash\nbash .\u002Fdatasets\u002Fdownload_dataset.sh horse2zebra\n```\n- Train a model:\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model 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\u002Fhorse2zebra name=horse2zebra_model gpu=0 cudnn=0 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### Test\n- Finally, test the model:\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model phase=test th test.lua\n```\nThe test results will be saved to an HTML file here: `.\u002Fresults\u002Fhorse2zebra_model\u002Flatest_test\u002Findex.html`.\n\n\n## Model Zoo\nDownload the pre-trained models with the following script. The model will be saved to `.\u002Fcheckpoints\u002Fmodel_name\u002Flatest_net_G.t7`.\n```bash\nbash .\u002Fpretrained_models\u002Fdownload_model.sh model_name\n```\n- `orange2apple` (orange -> apple) and `apple2orange`: trained on ImageNet categories `apple` and `orange`.\n- `horse2zebra` (horse -> zebra) and `zebra2horse` (zebra -> horse): trained on ImageNet categories `horse` and `zebra`.\n- `style_monet` (landscape photo -> Monet painting style),  `style_vangogh` (landscape photo  -> Van Gogh painting style), `style_ukiyoe` (landscape photo  -> Ukiyo-e painting style), `style_cezanne` (landscape photo  -> Cezanne painting style): trained on paintings and Flickr landscape photos.\n- `monet2photo` (Monet paintings -> real landscape): trained on paintings and Flickr landscape photographs.\n- `cityscapes_photo2label` (street scene -> label) and `cityscapes_label2photo` (label -> street scene): trained on the Cityscapes dataset.\n- `map2sat` (map -> aerial photo) and `sat2map` (aerial photo -> map): trained on Google maps.\n- `iphone2dslr_flower` (iPhone photos of flowers -> DSLR photos of flowers): trained on Flickr photos.\n\nCPU models can be downloaded using:\n```bash\nbash pretrained_models\u002Fdownload_model.sh \u003Cname>_cpu\n```\n, where `\u003Cname>` can be `horse2zebra`, `style_monet`, etc. You just need to append `_cpu` to the target model.\n\n## Training and Test Details\nTo train a model,  \n```bash\nDATA_ROOT=\u002Fpath\u002Fto\u002Fdata\u002F name=expt_name th train.lua\n```\nModels are saved to `.\u002Fcheckpoints\u002Fexpt_name` (can be changed by passing `checkpoint_dir=your_dir` in train.lua).  \nSee `opt_train` in `options.lua` for additional training options.\n\nTo test the model,\n```bash\nDATA_ROOT=\u002Fpath\u002Fto\u002Fdata\u002F name=expt_name phase=test th test.lua\n```\nThis will run the model named `expt_name` in both directions on all images in `\u002Fpath\u002Fto\u002Fdata\u002FtestA` and `\u002Fpath\u002Fto\u002Fdata\u002FtestB`.  \nA webpage with result images will be saved to `.\u002Fresults\u002Fexpt_name` (can be changed by passing `results_dir=your_dir` in test.lua).  \nSee `opt_test` in `options.lua` for additional test options. Please use `model=one_direction_test` if you only would like to generate outputs of the trained network in only one direction, and specify `which_direction=AtoB` or `which_direction=BtoA` to set the direction.\n\nThere are other options that can be used. For example, you can specify `resize_or_crop=crop` option to avoid resizing the image to squares. This is indeed how we trained GTA2Cityscapes model in the projet [webpage](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F) and [Cycada](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1711.03213.pdf) model. We prepared the images at 1024px resolution, and used `resize_or_crop=crop fineSize=360` to work with the cropped images of size 360x360. We also used `lambda_identity=1.0`.\n\n## Datasets\nDownload the datasets using the following script. Many of the datasets were 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 the [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)]. Note: Due to license issue, we do not host the dataset on our repo. Please download the dataset directly from the Cityscapes webpage. Please refer to `.\u002Fdatasets\u002Fprepare_cityscapes_dataset.py` for more detail.\n- `maps`: 1096 training images scraped from Google Maps.\n- `horse2zebra`: 939 horse images and 1177 zebra images downloaded from [ImageNet](http:\u002F\u002Fwww.image-net.org\u002F) using the keywords `wild horse` and `zebra`\n- `apple2orange`: 996 apple images and 1020 orange images downloaded from [ImageNet](http:\u002F\u002Fwww.image-net.org\u002F) using the keywords `apple` and `navel orange`.\n- `summer2winter_yosemite`: 1273 summer Yosemite images and 854 winter Yosemite images were downloaded using Flickr API. See more details in our paper.\n- `monet2photo`, `vangogh2photo`, `ukiyoe2photo`, `cezanne2photo`: The art images were downloaded from [Wikiart](https:\u002F\u002Fwww.wikiart.org\u002F). The real photos are downloaded from Flickr using the combination of the tags *landscape* and *landscapephotography*. The training set size of each class is Monet:1074, Cezanne:584, Van Gogh:401, Ukiyo-e:1433, Photographs:6853.\n- `iphone2dslr_flower`: both classes of images were downloaded from Flickr. The training set size of each class is iPhone:1813, DSLR:3316. See more details in our paper.\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\n## Setup Training and Test data\nTo train CycleGAN model on your own datasets, you need to create a data folder with two subdirectories `trainA` and `trainB` that contain images from domain A and B. You can test your model on your training set by setting ``phase='train'`` in  `test.lua`. You can also create subdirectories `testA` and `testB` if you have test data.\n\nYou should **not** expect our method to work on just any random combination of input and output datasets (e.g. `cats\u003C->keyboards`). From our experiments, we find it works better if two datasets share similar visual content. For example, `landscape painting\u003C->landscape photographs` works much better than `portrait painting \u003C-> landscape photographs`. `zebras\u003C->horses` achieves compelling results while `cats\u003C->dogs` completely fails.  See the following section for more discussion.\n\n\n## Failure cases\n\u003Cimg align=\"left\" style=\"padding:10px\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_9a6aa09af143.jpg\" width=320>\n\nOur model does not work well when the test image is rather different from the images on which the model is trained, as is the case in the figure to the left (we trained on horses and zebras without riders, but test here one a horse with a rider).  See additional typical failure cases [here](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002Fimages\u002Ffailures.jpg). On translation tasks that involve color and texture changes, like many of those reported above, the method often succeeds. We have also explored tasks that require geometric changes, with little success. For example, on the task of `dog\u003C->cat` transfiguration, the learned translation degenerates into making minimal changes to the input. We also observe a lingering gap between the results achievable with paired training data and those achieved by our unpaired method. In some cases, this gap may be very hard -- or even impossible,-- to close: for example, our method sometimes permutes the labels for tree and building in the output of the cityscapes photos->labels task.\n\n\n\n## Citation\nIf you use this code for your research, please cite our [paper](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F):\n\n```\n@inproceedings{CycleGAN2017,\n  title={Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networkss},\n  author={Zhu, Jun-Yan and Park, Taesung and Isola, Phillip and Efros, Alexei A},\n  booktitle={Computer Vision (ICCV), 2017 IEEE International Conference on},\n  year={2017}\n}\n\n```\n\n\n## Related Projects:\n**[contrastive-unpaired-translation](https:\u002F\u002Fgithub.com\u002Ftaesungp\u002Fcontrastive-unpaired-translation) (CUT)**\u003Cbr>\n**[pix2pix-Torch](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix) | [pix2pixHD](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fpix2pixHD) |\n[BicycleGAN](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FBicycleGAN) | [vid2vid](https:\u002F\u002Ftcwang0509.github.io\u002Fvid2vid\u002F) | [SPADE\u002FGauGAN](https:\u002F\u002Fgithub.com\u002FNVlabs\u002FSPADE)**\u003Cbr>\n**[iGAN](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FiGAN) | [GAN Dissection](https:\u002F\u002Fgithub.com\u002FCSAILVision\u002FGANDissect) | [GAN Paint](http:\u002F\u002Fganpaint.io\u002F)**\n\n## Cat Paper Collection\nIf you love cats, and love reading cool graphics, vision, and ML papers, please check out the Cat Paper [Collection](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCatPapers).  \n\n\n## Acknowledgments\nCode borrows from [pix2pix](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix) and [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). The generative network is adopted from [neural-style](https:\u002F\u002Fgithub.com\u002Fjcjohnson\u002Fneural-style) with [Instance Normalization](https:\u002F\u002Fgithub.com\u002FDmitryUlyanov\u002Ftexture_nets\u002Fblob\u002Fmaster\u002FInstanceNormalization.lua).\n","\u003Cimg src='https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_7567749554db.gif' align=\"right\" width=384>\n\n\u003Cbr>\u003Cbr>\u003Cbr>\n\n# CycleGAN\n### [PyTorch](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix) | [项目页面](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F) |   [论文](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1703.10593.pdf)\n\n基于 Torch 的实现，用于学习图像到图像的转换（即 [pix2pix](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix)），**无需**输入输出配对数据，例如：\n\n**新增**: 请查看 [contrastive-unpaired-translation](https:\u002F\u002Fgithub.com\u002Ftaesungp\u002Fcontrastive-unpaired-translation) (CUT)，这是我们全新的无配对图像到图像转换模型，支持快速且内存高效的训练。\n\n\u003Cimg src=\"https0:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002Fimages\u002Fteaser_high_res.jpg\" width=\"1000px\"\u002F>\n\n[使用循环一致性对抗网络进行无配对图像到图像转换](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F)  \n [朱俊彦](https:\u002F\u002Fpeople.eecs.berkeley.edu\u002F~junyanz\u002F)\\*,  [朴泰成](https:\u002F\u002Ftaesung.me\u002F)\\*, [菲利普·伊索拉](http:\u002F\u002Fweb.mit.edu\u002Fphillipi\u002F), [阿列克谢·A·埃夫罗斯](https:\u002F\u002Fpeople.eecs.berkeley.edu\u002F~efros\u002F)  \n 伯克利人工智能研究实验室，加州大学伯克利分校  \n 在 ICCV 2017 上发表。（\\* 共同第一作者）  \n\n本包包含 CycleGAN、[pix2pix](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix)，以及其他方法，如 [BiGAN](https:\u002F\u002Farxiv.org\u002Fabs\u002F1605.09782)\u002F[ALI](https:\u002F\u002Fishmaelbelghazi.github.io\u002FALI\u002F) 和苹果公司的论文 [S+U 学习](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1612.07828.pdf)。  \n代码由 [朱俊彦](https:\u002F\u002Fgithub.com\u002Fjunyanz) 和 [朴泰成](https:\u002F\u002Fgithub.com\u002Ftaesung) 编写。  \n**更新**: 请查看 CycleGAN 和 pix2pix 的 [PyTorch 实现](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix)。  \nPyTorch 版本正在积极开发中，其结果可与或优于当前的 Torch 版本。\n\n## 其他实现：\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fleehomyc\u002Fcyclegan-1\"> [TensorFlow]\u003C\u002Fa> (由 Harry Yang),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Farchitrathore\u002FCycleGAN\u002F\">[TensorFlow]\u003C\u002Fa> (由 Archit Rathore),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fvanhuyz\u002FCycleGAN-TensorFlow\">[TensorFlow]\u003C\u002Fa> (由 Van Huy),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FXHUJOY\u002FCycleGAN-tensorflow\">[TensorFlow]\u003C\u002Fa> (由 Xiaowei Hu),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FLynnHo\u002FCycleGAN-Tensorflow-Simple\"> [TensorFlow-简单]\u003C\u002Fa> (由 Zhenliang He),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fluoxier\u002FCycleGAN_Tensorlayer\"> [TensorLayer]\u003C\u002Fa> (由 luoxier),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FAixile\u002Fchainer-cyclegan\">[Chainer]\u003C\u002Fa> (由 Yanghua Jin),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fyunjey\u002Fmnist-svhn-transfer\">[极简 PyTorch]\u003C\u002Fa> (由 yunjey),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FLdpe2G\u002FDeepLearningForFun\u002Ftree\u002Fmaster\u002FMxnet-Scala\u002FCycleGAN\">[Mxnet]\u003C\u002Fa> (由 Ldpe2G),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Ftjwei\u002FGANotebooks\">[lasagne\u002FKeras]\u003C\u002Fa> (由 tjwei),\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fsimontomaskarlsson\u002FCycleGAN-Keras\">[Keras]\u003C\u002Fa> (由 Simon Karlsson)\u003C\u002Fp>\n\u003C\u002Ful>\n\n## 应用\n### 莫奈画作转照片\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_ef2a3a8bac9b.jpg\" width=\"1000px\"\u002F>\n\n### 收藏级风格迁移\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_4d78b4c2906f.jpg\" width=\"1000px\"\u002F>\n\n### 物体变形\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_fb0d72ed12b8.jpg\" width=\"1000px\"\u002F>\n\n### 季节转换\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_1196c5c8aed2.jpg\" width=\"1000px\"\u002F>\n\n### 照片增强：浅景深效果\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_377c9c38c004.jpg\" width=\"1000px\"\u002F>\n\n\n\n## 前提条件\n- Linux 或 OSX\n- NVIDIA GPU + CUDA CuDNN（CPU 模式和不带 CuDNN 的 CUDA 可能稍作修改后也能运行，但未经测试）\n- 对于 MAC 用户，需要安装 Linux\u002FGNU 命令 `gfind` 和 `gwc`，可通过 `brew install findutils coreutils` 进行安装。\n\n## 快速开始\n### 安装\n- 从 https:\u002F\u002Fgithub.com\u002Ftorch\u002Fdistro 安装 torch 及其依赖项\n- 安装 torch 包 `nngraph`、`class`、`display`\n```bash\nluarocks install nngraph\nluarocks install class\nluarocks install https:\u002F\u002Fraw.githubusercontent.com\u002Fszym\u002Fdisplay\u002Fmaster\u002Fdisplay-scm-0.rockspec\n```\n- 克隆此仓库：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\ncd CycleGAN\n```\n\n### 应用预训练模型\n- 下载测试照片（由 [阿列克谢·埃夫罗斯](https:\u002F\u002Fwww.flickr.com\u002Fphotos\u002Faaefros) 拍摄）：\n```\nbash .\u002Fdatasets\u002Fdownload_dataset.sh ae_photos\n```\n- 下载预训练模型 `style_cezanne`（对于 CPU 模型，请使用 `style_cezanne_cpu`）：\n```\nbash .\u002Fpretrained_models\u002Fdownload_model.sh style_cezanne\n```\n- 现在，让我们生成保罗·塞尚风格的图像：\n```\nDATA_ROOT=.\u002Fdatasets\u002Fae_photos name=style_cezanne_pretrained model=one_direction_test phase=test loadSize=256 fineSize=256 resize_or_crop=\"scale_width\" th test.lua\n```\n测试结果将保存到 `.\u002Fresults\u002Fstyle_cezanne_pretrained\u002Flatest_test\u002Findex.html`。  \n更多预训练模型请参阅 [模型库](#model-zoo)。  \n`.\u002Fexamples\u002Ftest_vangogh_style_on_ae_photos.sh` 是一个示例脚本，用于下载梵高风格的预训练网络，并在埃夫罗斯的照片上运行它。\n\n### 训练\n- 下载数据集（例如来自 ImageNet 的斑马和马的图片）：\n```bash\nbash .\u002Fdatasets\u002Fdownload_dataset.sh horse2zebra\n```\n- 训练模型：\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model th train.lua\n```\n- （仅限 CPU）相同的训练命令，但不使用 GPU 或 CUDNN。通过设置环境变量 ```gpu=0 cudnn=0``` 强制仅使用 CPU：\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model gpu=0 cudnn=0 th train.lua\n```\n- （可选）启动显示服务器，以便在模型训练时查看结果。（有关详细信息，请参阅 [显示界面](#display-ui)）：\n```bash\nth -ldisplay.start 8000 0.0.0.0\n```\n\n### 测试\n- 最后，测试模型：\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model phase=test th test.lua\n```\n测试结果将保存到此处的 HTML 文件中：`.\u002Fresults\u002Fhorse2zebra_model\u002Flatest_test\u002Findex.html`。\n\n## 模型 zoo\n使用以下脚本下载预训练模型。模型将保存到 `.\u002Fcheckpoints\u002Fmodel_name\u002Flatest_net_G.t7`。\n```bash\nbash .\u002Fpretrained_models\u002Fdownload_model.sh model_name\n```\n- `orange2apple`（橙子 → 苹果）和 `apple2orange`：在 ImageNet 的 `apple` 和 `orange` 类别上训练。\n- `horse2zebra`（马 → 斑马）和 `zebra2horse`（斑马 → 马）：在 ImageNet 的 `horse` 和 `zebra` 类别上训练。\n- `style_monet`（风景照片 → 莫奈风格画作）、`style_vangogh`（风景照片 → 梵高风格画作）、`style_ukiyoe`（风景照片 → 浮世绘风格画作）、`style_cezanne`（风景照片 → 塞尚风格画作）：在绘画作品和 Flickr 风景照片上训练。\n- `monet2photo`（莫奈画作 → 真实风景）：在绘画作品和 Flickr 风景照片上训练。\n- `cityscapes_photo2label`（街景 → 标签）和 `cityscapes_label2photo`（标签 → 街景）：在 Cityscapes 数据集上训练。\n- `map2sat`（地图 → 航拍图）和 `sat2map`（航拍图 → 地图）：在 Google 地图上训练。\n- `iphone2dslr_flower`（iPhone 花卉照片 → 单反花卉照片）：在 Flickr 照片上训练。\n\nCPU 版本的模型可以通过以下命令下载：\n```bash\nbash pretrained_models\u002Fdownload_model.sh \u003Cname>_cpu\n```\n其中 `\u003Cname>` 可以是 `horse2zebra`、`style_monet` 等。只需在目标模型名称后加上 `_cpu` 即可。\n\n## 训练与测试细节\n要训练一个模型，可以运行：\n```bash\nDATA_ROOT=\u002Fpath\u002Fto\u002Fdata\u002F name=expt_name th train.lua\n```\n模型将保存到 `.\u002Fcheckpoints\u002Fexpt_name` 目录下（可通过在 `train.lua` 中传递 `checkpoint_dir=your_dir` 参数来更改）。更多训练选项请参阅 `options.lua` 中的 `opt_train`。\n\n要测试模型，可以运行：\n```bash\nDATA_ROOT=\u002Fpath\u002Fto\u002Fdata\u002F name=expt_name phase=test th test.lua\n```\n这将在 `\u002Fpath\u002Fto\u002Fdata\u002FtestA` 和 `\u002Fpath\u002Fto\u002Fdata\u002FtestB` 中的所有图像上以双向方式运行名为 `expt_name` 的模型。结果图像的网页将保存到 `.\u002Fresults\u002Fexpt_name` 目录下（可通过在 `test.lua` 中传递 `results_dir=your_dir` 参数来更改）。更多测试选项请参阅 `options.lua` 中的 `opt_test`。如果仅希望生成训练网络在一个方向上的输出，请使用 `model=one_direction_test`，并指定 `which_direction=AtoB` 或 `which_direction=BtoA` 来设置方向。\n\n此外，还有其他可选参数。例如，可以指定 `resize_or_crop=crop` 选项来避免将图像调整为正方形。我们在项目 [webpage](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F) 和 [Cycada](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1711.03213.pdf) 模型中正是这样做的。我们准备了分辨率为 1024px 的图像，并使用 `resize_or_crop=crop fineSize=360` 来处理裁剪后的 360x360 大小的图像。我们还使用了 `lambda_identity=1.0`。\n\n## 数据集\n使用以下脚本下载数据集。许多数据集由其他研究人员收集。如果您使用这些数据，请引用他们的论文。\n```bash\nbash .\u002Fdatasets\u002Fdownload_dataset.sh dataset_name\n```\n- `facades`：来自 [CMP Facades 数据集](http:\u002F\u002Fcmp.felk.cvut.cz\u002F~tylecr1\u002Ffacade\u002F) 的 400 张图像。[[引用](datasets\u002Fbibtex\u002Ffacades.tex)]\n- `cityscapes`：来自 [Cityscapes 训练集](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F) 的 2975 张图像。[[引用](datasets\u002Fbibtex\u002Fcityscapes.tex)] 注意：由于许可问题，我们未将该数据集托管在我们的仓库中。请直接从 Cityscapes 官网下载数据集。更多信息请参阅 `.\u002Fdatasets\u002Fprepare_cityscapes_dataset.py`。\n- `maps`：从 Google 地图抓取的 1096 张训练图像。\n- `horse2zebra`：从 ImageNet 下载的 939 张马图像和 1177 张斑马图像，关键词分别为 `wild horse` 和 `zebra`。\n- `apple2orange`：从 ImageNet 下载的 996 张苹果图像和 1020 张橙子图像，关键词分别为 `apple` 和 `navel orange`。\n- `summer2winter_yosemite`：通过 Flickr API 下载的 1273 张优胜美地夏季图像和 854 张冬季图像。更多详情请参阅我们的论文。\n- `monet2photo`、`vangogh2photo`、`ukiyoe2photo`、`cezanne2photo`：艺术图像来自 [Wikiart](https:\u002F\u002Fwww.wikiart.org\u002F)。真实照片则通过 Flickr 上 *landscape* 和 *landscapephotography* 标签组合下载。各类别训练集规模为：莫奈 1074 张，塞尚 584 张，梵高 401 张，浮世绘 1433 张，照片 6853 张。\n- `iphone2dslr_flower`：两类图像均来自 Flickr。训练集规模为 iPhone 1813 张，单反 3316 张。更多详情请参阅我们的论文。\n\n\n## 显示界面\n可选地，在训练和测试过程中显示图像时，可以使用 [display 包](https:\u002F\u002Fgithub.com\u002Fszym\u002Fdisplay)。\n\n- 安装方法：`luarocks install https:\u002F\u002Fraw.githubusercontent.com\u002Fszym\u002Fdisplay\u002Fmaster\u002Fdisplay-scm-0.rockspec`\n- 启动服务器：`th -ldisplay.start`\n- 在浏览器中打开此网址：[http:\u002F\u002Flocalhost:8000](http:\u002F\u002Flocalhost:8000)\n\n默认情况下，服务器监听本地回环地址。若需允许任何接口的外部连接，可传递 `0.0.0.0`：\n```bash\nth -ldisplay.start 8000 0.0.0.0\n```\n然后在浏览器中打开 `http:\u002F\u002F(hostname):(port)\u002F` 即可加载远程桌面。\n\n## 准备训练与测试数据\n要在您自己的数据集上训练 CycleGAN 模型，需要创建一个包含两个子目录 `trainA` 和 `trainB` 的数据文件夹，分别存放来自域 A 和 B 的图像。您可以通过在 `test.lua` 中设置 `phase='train'` 来在训练集上测试模型。如果有测试数据，也可以创建 `testA` 和 `testB` 子目录。\n\n请注意，**不要期望**我们的方法适用于任意随机的输入输出数据集组合（例如 `cats\u003C->keyboards`）。根据我们的实验，当两个数据集具有相似的视觉内容时，效果会更好。例如，`landscape painting\u003C->landscape photographs` 的效果远优于 `portrait painting \u003C-> landscape photographs`。`zebras\u003C->horses` 能取得令人信服的结果，而 `cats\u003C->dogs` 则完全失败。更多讨论请参见下文。\n\n## 失败案例\n\u003Cimg align=\"left\" style=\"padding:10px\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_readme_9a6aa09af143.jpg\" width=320>\n\n当测试图像与模型训练数据集中的图像差异较大时，我们的模型表现不佳。例如左图所示的情况（我们在没有骑手的马和斑马上进行训练，但在测试时却使用了一匹有骑手的马）。更多典型的失败案例请参见[这里](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002Fimages\u002Ffailures.jpg)。对于涉及颜色和纹理变化的翻译任务，如上文提到的许多例子，该方法通常能够取得成功。然而，我们也尝试过需要几何变换的任务，但收效甚微。例如，在“狗↔猫”转换任务中，学习到的翻译结果往往只是对输入图像做出极小的改动。此外，我们还观察到，使用成对训练数据所能达到的效果与我们无配对数据方法所取得的效果之间仍存在差距。在某些情况下，这种差距可能非常难以弥补，甚至根本无法弥合：比如，在城市景观照片→标签的任务中，我们的方法有时会将输出中的“树”和“建筑物”的标签互换。\n\n\n\n## 引用\n如果您在研究中使用了本代码，请引用我们的[论文](https:\u002F\u002Fjunyanz.github.io\u002FCycleGAN\u002F)：\n\n```\n@inproceedings{CycleGAN2017,\n  title={Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks},\n  author={Zhu, Jun-Yan and Park, Taesung and Isola, Phillip and Efros, Alexei A},\n  booktitle={Computer Vision (ICCV), 2017 IEEE International Conference on},\n  year={2017}\n}\n\n```\n\n\n## 相关项目：\n**[contrastive-unpaired-translation](https:\u002F\u002Fgithub.com\u002Ftaesungp\u002Fcontrastive-unpaired-translation) (CUT)**\u003Cbr>\n**[pix2pix-Torch](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix) | [pix2pixHD](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fpix2pixHD) |\n[BicycleGAN](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FBicycleGAN) | [vid2vid](https:\u002F\u002Ftcwang0509.github.io\u002Fvid2vid\u002F) | [SPADE\u002FGauGAN](https:\u002F\u002Fgithub.com\u002FNVlabs\u002FSPADE)**\u003Cbr>\n**[iGAN](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FiGAN) | [GAN Dissection](https:\u002F\u002Fgithub.com\u002FCSAILVision\u002FGANDissect) | [GAN Paint](http:\u002F\u002Fganpaint.io\u002F)**\n\n## 猫主题论文集\n如果您喜爱猫咪，并且喜欢阅读有关图形学、视觉和机器学习的精彩论文，请查看猫主题论文[集](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCatPapers)。  \n\n\n## 致谢\n代码借鉴了[pix2pix](https:\u002F\u002Fgithub.com\u002Fphillipi\u002Fpix2pix)和[DCGAN](https:\u002F\u002Fgithub.com\u002Fsoumith\u002Fdcgan.torch)。数据加载器则基于[DCGAN](https:\u002F\u002Fgithub.com\u002Fsoumith\u002Fdcgan.torch)和[Context-Encoder](https:\u002F\u002Fgithub.com\u002Fpathak22\u002Fcontext-encoder)进行了修改。生成网络采用了[neural-style](https:\u002F\u002Fgithub.com\u002Fjcjohnson\u002Fneural-style)的架构，并结合了[Instance Normalization](https:\u002F\u002Fgithub.com\u002FDmitryUlyanov\u002Ftexture_nets\u002Fblob\u002Fmaster\u002FInstanceNormalization.lua)技术。","# CycleGAN 快速上手指南\n\nCycleGAN 是一个用于**无配对图像到图像翻译**的开源项目。它无需成对的训练数据（如“马”和“斑马”的一一对应照片），即可学习两个不同领域图像之间的风格转换（例如：马变斑马、照片变油画、夏季变冬季等）。\n\n> **注意**：本指南基于官方提供的 Torch (Lua) 版本。官方强烈推荐使用更新的 **PyTorch 版本** ([pytorch-CycleGAN-and-pix2pix](https:\u002F\u002Fgithub.com\u002Fjunyanz\u002Fpytorch-CycleGAN-and-pix2pix))，其维护更活跃且性能更佳。若需使用 PyTorch 版本，请参考其对应仓库。以下内容为原始 Torch 版本的快速上手流程。\n\n## 1. 环境准备\n\n在开始之前，请确保您的系统满足以下要求：\n\n*   **操作系统**: Linux 或 macOS (OSX)。\n*   **硬件**: NVIDIA GPU + CUDA + CuDNN（推荐）。\n    *   *注：CPU 模式也可运行，但速度较慢；未测试无 CuDNN 的 CUDA 环境。*\n*   **软件依赖**:\n    *   [Torch](http:\u002F\u002Ftorch.ch\u002F) 深度学习框架。\n    *   macOS 用户需安装 GNU 命令工具：`brew install findutils coreutils` (以获取 `gfind` 和 `gwc`)。\n\n## 2. 安装步骤\n\n### 2.1 安装 Torch 及依赖包\n首先安装 Torch 核心框架（参考 [Torch 官方安装指南](https:\u002F\u002Fgithub.com\u002Ftorch\u002Fdistro)），然后安装本项目所需的 Lua 包：\n\n```bash\nluarocks install nngraph\nluarocks install class\nluarocks install https:\u002F\u002Fraw.githubusercontent.com\u002Fszym\u002Fdisplay\u002Fmaster\u002Fdisplay-scm-0.rockspec\n```\n\n### 2.2 克隆项目代码\n将 CycleGAN 代码库克隆到本地：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\ncd CycleGAN\n```\n\n## 3. 基本使用\n\n### 3.1 使用预训练模型（快速体验）\n无需训练，直接下载预训练模型对图片进行风格迁移（例如将照片转换为塞尚画风）。\n\n1.  **下载测试数据集**（由 Alexei Efros 拍摄的照片）：\n    ```bash\n    bash .\u002Fdatasets\u002Fdownload_dataset.sh ae_photos\n    ```\n\n2.  **下载预训练模型**（此处以 `style_cezanne` 为例，CPU 用户请下载 `style_cezanne_cpu`）：\n    ```bash\n    bash .\u002Fpretrained_models\u002Fdownload_model.sh style_cezanne\n    ```\n\n3.  **生成风格化图像**：\n    ```bash\n    DATA_ROOT=.\u002Fdatasets\u002Fae_photos name=style_cezanne_pretrained model=one_direction_test phase=test loadSize=256 fineSize=256 resize_or_crop=\"scale_width\" th test.lua\n    ```\n\n4.  **查看结果**：\n    生成的图片将保存在 `.\u002Fresults\u002Fstyle_cezanne_pretrained\u002Flatest_test\u002Findex.html`，用浏览器打开即可查看。\n\n### 3.2 训练自己的模型\n以“马 \u003C-> 斑马”数据集为例，训练一个双向转换模型。\n\n1.  **下载数据集**：\n    ```bash\n    bash .\u002Fdatasets\u002Fdownload_dataset.sh horse2zebra\n    ```\n\n2.  **开始训练**（默认使用 GPU）：\n    ```bash\n    DATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model th train.lua\n    ```\n    *   *仅使用 CPU 训练*：添加环境变量 `gpu=0 cudnn=0`。\n        ```bash\n        DATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model gpu=0 cudnn=0 th train.lua\n        ```\n\n3.  **可视化训练过程（可选）**：\n    启动显示服务器以实时监控训练效果：\n    ```bash\n    th -ldisplay.start 8000 0.0.0.0\n    ```\n    然后在浏览器访问 `http:\u002F\u002Flocalhost:8000`。\n\n4.  **测试训练好的模型**：\n    训练完成后，运行以下命令生成测试结果：\n    ```bash\n    DATA_ROOT=.\u002Fdatasets\u002Fhorse2zebra name=horse2zebra_model phase=test th test.lua\n    ```\n    结果将保存至 `.\u002Fresults\u002Fhorse2zebra_model\u002Flatest_test\u002Findex.html`。\n\n### 3.3 自定义数据集训练\n若要使用自己的数据进行训练，请按以下结构组织数据文件夹：\n\n```text\ndatasets\u002F\n    your_dataset_name\u002F\n        trainA\u002F  (存放领域 A 的图片)\n        trainB\u002F  (存放领域 B 的图片)\n        testA\u002F   (可选，测试集 A)\n        testB\u002F   (可选，测试集 B)\n```\n\n运行训练命令时替换数据集名称：\n```bash\nDATA_ROOT=.\u002Fdatasets\u002Fyour_dataset_name name=expt_name th train.lua\n```\n\n> **提示**：CycleGAN 在两个具有相似视觉内容的领域间效果最佳（如“风景照 \u003C-> 风景画”、“马 \u003C-> 斑马”）。若两个领域差异过大（如“猫 \u003C-> 键盘”），效果可能不佳。","一家独立游戏开发团队正在为一款奇幻题材的游戏制作资产，需要将大量现实世界的风景照片快速转化为统一的手绘油画风格，以匹配游戏的美术设定。\n\n### 没有 CycleGAN 时\n- **数据配对成本极高**：传统风格迁移模型需要成对的“原图 - 目标图”进行训练，美术团队必须手动绘制每张照片对应的油画版，耗时数月且人力成本巨大。\n- **风格一致性难保证**：不同画师手工转绘的照片在笔触、色调和光影处理上存在差异，导致游戏场景视觉风格割裂，后期需花费大量时间统一调整。\n- **迭代效率低下**：一旦策划决定微调美术风格（如从印象派转为厚涂风），所有已处理的图片需重新人工绘制，无法快速响应需求变更。\n- **复杂场景处理受限**：对于包含动态元素（如流水、云层）或复杂结构的场景，手动转绘难以保留原始构图逻辑，容易丢失关键细节。\n\n### 使用 CycleGAN 后\n- **无需成对数据训练**：CycleGAN 直接利用未配对的“实景照片集”和“油画作品集”即可学习映射关系，团队仅需收集素材，省去了繁琐的手工配对环节。\n- **自动化风格统一**：模型能自动提取油画的笔触纹理与色彩分布，将数百张风景照批量转化为风格高度一致的遊戲資產，确保视觉体验流畅自然。\n- **敏捷风格切换**：只需更换训练数据集（如替换为水彩画集），即可在短时间内重新生成全新风格的场景图，极大提升了美术迭代的灵活性。\n- **智能内容保持**：凭借循环一致性损失机制，CycleGAN 在转换风格的同时完美保留了原图的物体结构与空间布局，流水依然流动，建筑轮廓清晰可见。\n\nCycleGAN 通过突破成对数据的限制，让游戏团队以极低的成本实现了大规模、高质量且可灵活迭代的美术风格迁移。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fjunyanz_CycleGAN_75677495.gif","junyanz","Jun-Yan Zhu","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fjunyanz_aea33318.jpg","Understanding and creating pixels."," Carnegie Mellon University:","Pittsburgh, PA",null,"junyanz89","https:\u002F\u002Fwww.cs.cmu.edu\u002F~junyanz\u002F","https:\u002F\u002Fgithub.com\u002Fjunyanz",[87,91,95,99],{"name":88,"color":89,"percentage":90},"Lua","#000080",94.7,{"name":92,"color":93,"percentage":94},"Python","#3572A5",3.2,{"name":96,"color":97,"percentage":98},"Shell","#89e051",1.6,{"name":100,"color":101,"percentage":102},"TeX","#3D6117",0.5,12851,1970,"2026-04-03T10:51:03","NOASSERTION",4,"Linux, macOS","需要 NVIDIA GPU + CUDA CuDNN（CPU 模式可能可用但未测试），未指定具体显存大小和 CUDA 版本","未说明",{"notes":112,"python":113,"dependencies":114},"该工具基于 Lua 语言的 Torch 框架（非 PyTorch 或 Python）。Mac 用户需通过 brew 安装 GNU 命令工具 `gfind` 和 `gwc`。官方强烈建议查看其新的 PyTorch 实现版本，因为当前 Lua 版本已不再积极开发。","未说明 (基于 Torch\u002FLua 框架，非 Python)",[115,116,117,118,119,120],"Torch (Lua)","nngraph","class","display","CUDA","CuDNN",[14,13],[123,124,125,126,127,128,129,130,131,132,133],"gan","generative-adversarial-network","deep-learning","image-generation","image-manipulation","cyclegan","pix2pix","gans","computer-vision","computer-graphics","torch","2026-03-27T02:49:30.150509","2026-04-06T11:31:00.185774",[137,142,146,150,155,160,165],{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},17283,"两个域（Domain）的图像数量不平衡（例如 A 域 65 万张，B 域 2 万张）会影响训练效果吗？需要数量一致吗？","图像数量越多越好，但 CycleGAN 在小数据集（如 200 或 1000 张图像）上也能产生合理的结果。两个域的图像数量不需要完全一致或保持特定比例，不平衡的数据集通常也可以正常训练。","https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\u002Fissues\u002F93",{"id":143,"question_zh":144,"answer_zh":145,"source_url":141},17284,"测试集（test split）在训练过程中有什么作用？应该如何划分数据集？","测试集主要用于评估模型性能，不参与训练过程中的梯度更新。在测试阶段，你可以通过指定 `resize_or_crop=\"scale_width\"` 参数来处理不同尺寸的图像。即使训练时使用了方形裁剪，测试时仍然可以在矩形图像上进行推理（例如马转斑马的任务）。",{"id":147,"question_zh":148,"answer_zh":149,"source_url":141},17285,"如何处理非正方形图像（如长宽比不为 1:1）？应该使用哪个预处理参数？","不需要强制图像长宽比为特定值。你可以使用 `resize_or_crop` 标志来控制预处理步骤。对于非正方形图像，建议在测试时设置 `resize_or_crop=\"scale_width\"` 或 `scale_height`，这样可以保留原始纵横比进行缩放，而不是强制裁剪成正方形。",{"id":151,"question_zh":152,"answer_zh":153,"source_url":154},17286,"运行预训练模型时出现 CUDA 'out of memory'（显存不足）错误怎么办？","有两种主要解决方法：\n1. 如果只关注结果而不介意速度，可以切换到 CPU 模式运行。\n2. 降低 `fineSize` 参数的值（例如从 256 降到 128），这将减少显存占用并解决该问题。","https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\u002Fissues\u002F15",{"id":156,"question_zh":157,"answer_zh":158,"source_url":159},17287,"CycleGAN 是否需要成对的图像数据（即同一场景源域和目标域的图片）？","不需要。CycleGAN 的核心优势就是无需成对数据（Unpaired）。你只需要准备两组随机图像（例如一组笑脸和一组非笑脸），它们不需要是同一个人在不同状态下的照片，随机采集的图像集即可工作。","https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\u002Fissues\u002F111",{"id":161,"question_zh":162,"answer_zh":163,"source_url":164},17288,"运行命令时提示 'th: command not found' 如何解决？","这表示未正确安装或未激活 Torch 环境。解决方法如下：\n1. 克隆 Torch 仓库：`git clone https:\u002F\u002Fgithub.com\u002Fnagadomi\u002Fdistro.git torch --recursive`\n2. 进入目录并安装依赖：`cd torch && bash install-deps && .\u002Finstall.sh`\n3. 激活环境：`. .\u002Finstall\u002Fbin\u002Ftorch-activate`\n4. 验证安装：运行 `th` 看是否进入 Torch 交互界面。\n另外，作者建议查看 PyTorch 版本的实现以获得更好的支持和更简单的安装流程。","https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\u002Fissues\u002F82",{"id":166,"question_zh":167,"answer_zh":168,"source_url":169},17289,"在多 GPU 机器上运行代码速度反而变慢且显存占用异常，如何解决？","原生的 Torch 实现可能在多 GPU 环境下存在效率瓶颈。可以参考 `soumith\u002Fimagenet-multiGPU.torch` 仓库的代码来实现多 GPU 支持。此外，维护者强烈建议使用 PyTorch 版本的 CycleGAN 实现，因为它对多 GPU 训练有更好的支持和优化。","https:\u002F\u002Fgithub.com\u002Fjunyanz\u002FCycleGAN\u002Fissues\u002F58",[]]