[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Justin-Tan--generative-compression":3,"tool-Justin-Tan--generative-compression":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},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,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},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 真正成长为懂上",146793,2,"2026-04-08T23:32:35",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":77,"owner_email":76,"owner_twitter":76,"owner_website":78,"owner_url":79,"languages":80,"stars":89,"forks":90,"last_commit_at":91,"license":92,"difficulty_score":93,"env_os":94,"env_gpu":95,"env_ram":94,"env_deps":96,"category_tags":102,"github_topics":103,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":109,"updated_at":110,"faqs":111,"releases":142},5711,"Justin-Tan\u002Fgenerative-compression","generative-compression","TensorFlow Implementation of Generative Adversarial Networks for Extreme Learned Image Compression","generative-compression 是一个基于 TensorFlow 实现的开源项目，旨在利用生成对抗网络（GAN）进行极致的学习型图像压缩。它复现了 Agustsson 等人提出的前沿算法，核心目标是解决传统压缩技术在极低码率下图像质量严重下降的难题。通过引入生成式模型，该工具能够在大幅减小文件体积的同时，利用 AI“脑补”出合理的纹理细节，从而显著提升人眼感知的视觉质量，尽管这可能导致重建图像与原始像素存在细微差异。\n\n该项目特别适合人工智能研究人员、深度学习开发者以及对新型图像编码技术感兴趣的工程师使用。用户可以通过提供的代码训练自定义模型，或直接使用预训练模型对图像进行压缩测试。其技术亮点在于采用了多尺度判别器和特征匹配损失函数，并支持结合语义地图的条件压缩模式，甚至能通过噪声采样生成更丰富的细节。需要注意的是，由于依赖较旧版本的 TensorFlow 环境，使用该工具需要一定的技术部署能力，更适合用于学术探索和技术验证，而非普通用户的日常图片处理。","# generative-compression\n\nTensorFlow Implementation for learned compression of images using Generative Adversarial Networks. The method was developed by Agustsson et. al. in [Generative Adversarial Networks for Extreme Learned Image Compression](https:\u002F\u002Farxiv.org\u002Fabs\u002F1804.02958). The proposed idea is very interesting and their approach is well-described.\n\n![Results from authors using C=4 bottleneck channels, global compression without semantic maps on the Kodak dataset](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_0af65195c72d.png)\n\n-----------------------------\n## Usage\nThe code depends on [Tensorflow 1.8](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow)\n```bash\n# Clone\n$ git clone https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression.git\n$ cd generative-compression\n\n# To train, check command line arguments\n$ python3 train.py -h\n# Run\n$ python3 train.py -opt momentum --name my_network\n```\nTraining is conducted with batch size 1 and reconstructed samples \u002F tensorboard summaries will be periodically written every certain number of steps (default is 128). Checkpoints are saved every 10 epochs. \n\nTo compress a single image:\n```bash\n# Compress\n$ python3 compress.py -r \u002Fpath\u002Fto\u002Fmodel\u002Fcheckpoint -i \u002Fpath\u002Fto\u002Fimage -o path\u002Fto\u002Foutput\u002Fimage\n```\nThe compressed image will be saved as a side-by-side comparison with the original image under the path specified in `directories.samples` in `config.py`. If you are using the provided pretrained model with noise sampling, retain the hyperparameters under `config_test` in `config.py`, otherwise the parameters during test time should match the parameters set during training.\n\n*Note:* If you're willing to pay higher bitrates in exchange for much higher perceptual quality, you may want to check out this implementation of [\"High-Fidelity Generative Image Compression\"](https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fhigh-fidelity-generative-compression), which is in the same vein but operates in higher bitrate regimes. Furthermore, it is capable of working with images of arbitrary size and resolution.\n\n## Results\nThese globally compressed images are from the test split of the Cityscapes `leftImg8bit` dataset. The decoder seems to hallunicate greenery in buildings, and vice-versa. \n\n#### Global conditional compression: Multiscale discriminator + feature-matching losses, C=8 channels - (compression to 0.072 bbp)\n**Epoch 38**\n![cityscapes_e38](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_7ee970d7d03f.png)\n**Epoch 44**\n![cityscapes_e44](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_76d15fac7cac.png)\n**Epoch 47**\n![cityscapes_e44](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_558fe77bbec3.png)\n**Epoch 48**\n![cityscapes_e44](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_5a2352e3fe0f.png)\n```\nShow quantized C=4,8,16 channels image comparison\n```\n| Generator Loss | Discriminator Loss |\n|-------|-------|\n|![gen_loss](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_ed4ad0cd5784.png) | ![discriminator_loss](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_bd6a9d225bef.png) |\n\n## Pretrained Model\nYou can find the pretrained model for global compression with a channel bottleneck of `C = 8` (corresponding to a 0.072 bpp representation) below. The model was subject to the multiscale discriminator and feature matching losses. Noise is sampled from a 128-dim normal distribution, passed through a DCGAN-like generator and concatenated to the quantized image representation. The model was trained for 55 epochs on the train split of the [Cityscapes](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F) `leftImg8bit` dataset for the images and used the `gtFine` dataset for the corresponding semantic maps. This should work with the default settings under `config_test` in `config.py`.\n\nA pretrained model for global conditional compression with a `C=8` bottleneck is also included. This model was, trained for 50 epochs with the same losses as above. Reconstruction is conditioned on semantic label maps (see the `cGAN\u002F` folder and 'Conditional GAN usage').\n\n* [Noise sampling model](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1gy6NJqlxflLDI1g9Rsileva-8G1ifsEC)\n* [Conditional GAN model](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1L3G4l8IQukNrsf3hjHv5xRhpNE77TD2k)\n\n** Warning: Tensorflow 1.3 was used to train the models, but it appears to load without problems on Tensorflow 1.8. Please raise an issue if you have any problems.\n\n## Details \u002F extensions\nThe network architectures are based on the description provided in the appendix of the original paper, which is in turn based on the paper [Perceptual Losses for Real-Time Style Transfer\nand Super-Resolution](https:\u002F\u002Fcs.stanford.edu\u002Fpeople\u002Fjcjohns\u002Feccv16\u002F) The multiscale discriminator loss used was originally proposed in the project [High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs](https:\u002F\u002Ftcwang0509.github.io\u002Fpix2pixHD\u002F), consult `network.py` for the implementation. If you would like to add an extension you can create a new method under the `Network` class, e.g.\n\n```python\n@staticmethod\ndef my_generator(z, **kwargs):\n    \"\"\"\n    Inputs:\n    z: sampled noise\n\n    Returns:\n    upsampled image\n    \"\"\"\n\n    return tf.random_normal([z.get_shape()[0], height, width, channels], seed=42)\n```\nTo change hyperparameters\u002Ftoggle features use the knobs in `config.py`. (Bad form maybe. but I find it easier than a 20-line `argparse` specification).\n\n### Data \u002F Setup\nTraining was done using the [ADE 20k dataset](http:\u002F\u002Fgroups.csail.mit.edu\u002Fvision\u002Fdatasets\u002FADE20K\u002F) and the [Cityscapes leftImg8bit dataset](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F). In the former case images are rescaled to width `512` px, and in the latter images are [resampled to `[512 x 1024]` prior to training](https:\u002F\u002Fwww.imagemagick.org\u002Fscript\u002Fcommand-line-options.php#resample). An example script for resampling using `Imagemagick` is provided under `data\u002F`. In each case, you will need to create a Pandas dataframe containing a single column: `path`, which holds the absolute\u002Frelative path to the images. This should be saved as a `HDF5` file, and you should provide the path to this under the `directories` class in `config.py`. Examples for the Cityscapes dataset are provided in the `data` directory. \n\n### Conditional GAN usage\nThe conditional GAN implementation for global compression is in the `cGAN` directory. The cGAN implementation appears to yield images with the highest image quality, but this implementation remains experimental. In this implementation generation is conditioned on the information in the semantic label map of the selected image. You will need to download the `gtFine` dataset of annotation maps and append a separate column `semantic_map_paths` to the Pandas dataframe pointing to the corresponding images from the `gtFine` dataset.\n\n### Dependencies\n* Python 3.6\n* [Pandas](https:\u002F\u002Fpandas.pydata.org\u002F)\n* [TensorFlow 1.8](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow)\n\n### Todo:\n* Incorporate GAN noise sampling into the reconstructed image. The authors state that this step is optional and that the sampled noise is combined with the quantized representation but don't provide further details. Currently the model samples from a normal distribution and upsamples this using a DCGAN-like generator (see `network.py`) to be concatenated with the quantized image representation `w_hat`, but this appears to substantially increase the 'hallunication factor' in the reconstructed images.\n* Integrate VGG loss.\n* Experiment with WGAN-GP. \n* Experiment with spectral normalization\u002F\n* Experiment with different generator architectures with noise sampling. \n* Extend to selective compression using semantic maps (contributions welcome).\n\n### Resources\n* [Generative Adversarial Networks for Extreme Learned Image Compression](https:\u002F\u002Fdata.vision.ee.ethz.ch\u002Faeirikur\u002Fextremecompression\u002F#publication)\n* [CycleGAN](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1703.10593.pdf)\n* [High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs](https:\u002F\u002Ftcwang0509.github.io\u002Fpix2pixHD\u002F)\n\n## More Results\n#### Global compression: Noise sampling, multiscale discriminator + feature-matching losses, C=8 channels - Compression to 0.072 bbp\n![cityscapes_e45](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_0ba93759a94e.png)\n![cityscapes_e47](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_25e1ffa65a2f.png)\n![cityscapes_e51](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_2fd277821dc5.png)\n![cityscapes_e53](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_376f1cb61f86.png)\n![cityscapes_e54](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_f0cd918208dd.png)\n![cityscapes_e55](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_800ee3612fe6.png)\n![cityscapes_e56](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_c1eca7f2f761.png)\n","# 生成式压缩\n\n基于生成对抗网络的图像学习压缩 TensorFlow 实现。该方法由 Agustsson 等人在 [极端学习图像压缩的生成对抗网络](https:\u002F\u002Farxiv.org\u002Fabs\u002F1804.02958) 中提出。他们的想法非常有趣，且方法描述得十分清晰。\n\n![作者使用 C=4 瓶颈通道、无语义图的全局压缩在 Kodak 数据集上的结果](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_0af65195c72d.png)\n\n-----------------------------\n## 使用方法\n代码依赖于 [TensorFlow 1.8](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow)\n```bash\n# 克隆\n$ git clone https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression.git\n$ cd generative-compression\n\n# 训练时，请查看命令行参数\n$ python3 train.py -h\n# 运行\n$ python3 train.py -opt momentum --name my_network\n```\n训练采用 batch size 1，重建样本和 TensorBoard 摘要会每隔一定步数（默认为 128 步）定期写入。每 10 个 epoch 保存一次检查点。\n\n压缩单张图片：\n```bash\n# 压缩\n$ python3 compress.py -r \u002Fpath\u002Fto\u002Fmodel\u002Fcheckpoint -i \u002Fpath\u002Fto\u002Fimage -o path\u002Fto\u002Foutput\u002Fimage\n```\n压缩后的图像将与原始图像并排对比，保存在 `config.py` 中 `directories.samples` 指定的路径下。如果您使用的是提供的预训练模型并进行噪声采样，请保留 `config.py` 中 `config_test` 下的超参数；否则，测试时的参数应与训练时设置的参数一致。\n\n*注：* 如果您愿意以更高的比特率换取更高的感知质量，可以尝试实现“高保真生成式图像压缩”([High-Fidelity Generative Image Compression](https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fhigh-fidelity-generative-compression))，它与本项目思路相同，但运行在更高的比特率区间。此外，该实现还能处理任意大小和分辨率的图像。\n\n## 结果\n这些全局压缩的图像来自 Cityscapes `leftImg8bit` 数据集的测试集。解码器似乎会在建筑物中“幻觉”出绿色植被，反之亦然。\n\n#### 全局条件压缩：多尺度判别器 + 特征匹配损失，C=8 通道 - （压缩至 0.072 bpp）\n**第 38 个 epoch**\n![cityscapes_e38](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_7ee970d7d03f.png)\n**第 44 个 epoch**\n![cityscapes_e44](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_76d15fac7cac.png)\n**第 47 个 epoch**\n![cityscapes_e44](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_558fe77bbec3.png)\n**第 48 个 epoch**\n![cityscapes_e44](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_5a2352e3fe0f.png)\n```\n展示量化后的 C=4、8、16 通道图像对比\n```\n| 生成器损失 | 判别器损失 |\n|-------|-------|\n|![gen_loss](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_ed4ad0cd5784.png) | ![discriminator_loss](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_bd6a9d225bef.png) |\n\n## 预训练模型\n您可以在下方找到全局压缩的预训练模型，其通道瓶颈为 `C = 8`（对应 0.072 bpp 表示）。该模型采用了多尺度判别器和特征匹配损失。噪声从 128 维正态分布中采样，经过类似 DCGAN 的生成器处理后与量化后的图像表示拼接。模型在 [Cityscapes](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F) `leftImg8bit` 数据集的训练集上训练了 55 个 epoch，并使用 `gtFine` 数据集作为对应的语义标签图。此模型应能配合 `config.py` 中 `config_test` 的默认设置正常工作。\n\n同时附带一个带有 `C=8` 瓶颈的全局条件压缩预训练模型。该模型同样使用上述损失函数训练了 50 个 epoch。重建过程以语义标签图为条件（详见 `cGAN\u002F` 文件夹及“条件 GAN 使用说明”）。\n\n* [噪声采样模型](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1gy6NJqlxflLDI1g9Rsileva-8G1ifsEC)\n* [条件 GAN 模型](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1L3G4l8IQukNrsf3hjHv5xRhpNE77TD2k)\n\n**警告：** 模型是用 TensorFlow 1.3 训练的，但在 TensorFlow 1.8 上加载并无问题。如有任何问题，请提交 issue。\n\n## 详情\u002F扩展\n网络架构基于原始论文附录中的描述，而该附录又参考了论文 [用于实时风格迁移和超分辨率的感知损失](https:\u002F\u002Fcs.stanford.edu\u002Fpeople\u002Fjcjohns\u002Feccv16\u002F)。所使用的多尺度判别器损失最初是在 [使用条件 GAN 进行高分辨率图像合成与语义操作](https:\u002F\u002Ftcwang0509.github.io\u002Fpix2pixHD\u002F) 项目中提出的，具体实现请参阅 `network.py`。若需添加扩展功能，可在 `Network` 类中创建新方法，例如：\n\n```python\n@staticmethod\ndef my_generator(z, **kwargs):\n    \"\"\"\n    输入：\n    z: 采样的噪声\n\n    输出：\n    上采样后的图像\n    \"\"\"\n\n    return tf.random_normal([z.get_shape()[0], height, width, channels], seed=42)\n```\n如需更改超参数或切换功能，可使用 `config.py` 中的配置项。（虽然可能不太规范，但我认为这样比编写 20 行的 `argparse` 更方便）。\n\n### 数据\u002F准备\n训练使用了 [ADE 20k 数据集](http:\u002F\u002Fgroups.csail.mit.edu\u002Fvision\u002Fdatasets\u002FADE20K\u002F) 和 [Cityscapes leftImg8bit 数据集](https:\u002F\u002Fwww.cityscapes-dataset.com\u002F)。前者将图像缩放至宽度 512 像素，后者则在训练前将图像重新采样至 `[512 x 1024]`（参见 [Imagemagick 命令行选项](https:\u002F\u002Fwww.imagemagick.org\u002Fscript\u002Fcommand-line-options.php#resample)）。`data\u002F` 目录下提供了使用 `Imagemagick` 重新采样的示例脚本。在每种情况下，您都需要创建一个包含单列 `path` 的 Pandas 数据框，其中存储图像的绝对或相对路径。该数据框应保存为 `HDF5` 文件，并将其路径提供给 `config.py` 中的 `directories` 类。`data` 目录中提供了 Cityscapes 数据集的示例。\n\n### 条件 GAN 使用\n全局压缩的条件 GAN 实现位于 `cGAN` 目录中。条件 GAN 实现似乎能生成质量最高的图像，但目前仍处于实验阶段。在此实现中，生成过程以所选图像的语义标签图信息为条件。您需要下载 `gtFine` 注释地图数据集，并在 Pandas 数据框中添加一列 `semantic_map_paths`，指向 `gtFine` 数据集中对应的图像。\n\n### 依赖项\n* Python 3.6\n* [Pandas](https:\u002F\u002Fpandas.pydata.org\u002F)\n* [TensorFlow 1.8](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow)\n\n### 待办事项：\n* 将 GAN 噪声采样融入重建图像中。作者指出这一步是可选的，采样的噪声会与量化表示相结合，但未提供更多细节。目前模型从正态分布中采样，并使用类似 DCGAN 的生成器上采样（参见 `network.py`），以将其与量化图像表示 `w_hat` 拼接在一起，但这似乎显著增加了重建图像中的“幻觉”成分。\n* 集成 VGG 损失。\n* 尝试 WGAN-GP。\n* 尝试谱归一化。\n* 探索不同带有噪声采样的生成器架构。\n* 扩展到使用语义图进行选择性压缩（欢迎贡献）。\n\n### 资源\n* [用于极端学习图像压缩的生成对抗网络](https:\u002F\u002Fdata.vision.ee.ethz.ch\u002Faeirikur\u002Fextremecompression\u002F#publication)\n* [CycleGAN](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1703.10593.pdf)\n* [基于条件 GAN 的高分辨率图像合成与语义操控](https:\u002F\u002Ftcwang0509.github.io\u002Fpix2pixHD\u002F)\n\n## 更多结果\n#### 全局压缩：噪声采样、多尺度判别器 + 特征匹配损失，C=8 通道 - 压缩至 0.072 bpp\n![cityscapes_e45](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_0ba93759a94e.png)\n![cityscapes_e47](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_25e1ffa65a2f.png)\n![cityscapes_e51](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_2fd277821dc5.png)\n![cityscapes_e53](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_376f1cb61f86.png)\n![cityscapes_e54](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_f0cd918208dd.png)\n![cityscapes_e55](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_800ee3612fe6.png)\n![cityscapes_e56](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_readme_c1eca7f2f761.png)","# generative-compression 快速上手指南\n\n本项目是基于 TensorFlow 的生成对抗网络（GAN）图像压缩实现，源自论文《Generative Adversarial Networks for Extreme Learned Image Compression》。它能够在极低码率下实现具有良好感知质量的图像重建。\n\n## 环境准备\n\n在开始之前，请确保您的系统满足以下要求：\n\n*   **操作系统**: Linux \u002F macOS (Windows 需自行配置 TensorFlow 1.x 环境)\n*   **Python 版本**: Python 3.6\n*   **核心框架**: TensorFlow 1.8 (模型训练基于 TF 1.3，但在 TF 1.8 上加载正常)\n*   **其他依赖**: Pandas\n\n**依赖安装命令：**\n\n```bash\npip install tensorflow==1.8 pandas\n```\n\n> **提示**：由于 TensorFlow 1.x 版本较老，若国内下载缓慢，建议使用清华或阿里镜像源加速安装：\n> `pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple tensorflow==1.8 pandas`\n\n## 安装步骤\n\n1.  **克隆仓库**\n    将项目代码下载到本地：\n\n    ```bash\n    git clone https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression.git\n    cd generative-compression\n    ```\n\n2.  **数据准备（可选）**\n    若需重新训练模型，需准备数据集（如 Cityscapes 或 ADE 20k）。\n    *   创建一个包含单列 `path` 的 Pandas DataFrame，存储图像的绝对或相对路径。\n    *   将其保存为 `HDF5` 文件。\n    *   在 `config.py` 的 `directories` 类中指定该文件的路径。\n    *   参考 `data\u002F` 目录下的示例脚本进行图像重采样处理。\n\n## 基本使用\n\n### 1. 训练模型\n\n运行训练脚本前，可查看命令行参数帮助：\n\n```bash\npython3 train.py -h\n```\n\n启动训练示例（使用 momentum 优化器，命名网络为 `my_network`）：\n\n```bash\npython3 train.py -opt momentum --name my_network\n```\n\n*   **说明**：默认 Batch Size 为 1。每隔一定步数（默认 128 步）会写入重建样本和 TensorBoard 摘要，每 10 个 epoch 保存一次检查点。\n\n### 2. 压缩单张图像\n\n使用预训练模型或训练好的检查点对单张图片进行压缩：\n\n```bash\npython3 compress.py -r \u002Fpath\u002Fto\u002Fmodel\u002Fcheckpoint -i \u002Fpath\u002Fto\u002Fimage -o path\u002Fto\u002Foutput\u002Fimage\n```\n\n*   `-r`: 模型检查点路径。\n*   `-i`: 输入图像路径。\n*   `-o`: 输出图像路径。\n\n**注意**：\n*   压缩后的图像将以“原图 - 重建图”并排对比的形式保存，具体保存位置由 `config.py` 中的 `directories.samples` 定义。\n*   若使用提供的带噪声采样的预训练模型，请保持 `config.py` 中 `config_test` 下的超参数不变；若是自定义训练模型，测试时的参数需与训练时保持一致。\n\n### 3. 使用预训练模型\n\n项目提供了两种全局压缩预训练模型（瓶颈通道数 C=8，约 0.072 bpp）：\n\n*   **噪声采样模型 (Noise sampling model)**: [下载链接](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1gy6NJqlxflLDI1g9Rsileva-8G1ifsEC)\n*   **条件 GAN 模型 (Conditional GAN model)**: [下载链接](https:\u002F\u002Fdrive.google.com\u002Fopen?id=1L3G4l8IQukNrsf3hjHv5xRhpNE77TD2k) (需配合语义标签图使用)\n\n下载后解压，将路径填入上述 `compress.py` 命令的 `-r` 参数即可运行。","某智慧城市项目组需要将大量高分辨率街道监控图像上传至云端进行归档分析，但受限于网络带宽和存储成本，传统压缩方案导致关键细节丢失严重。\n\n### 没有 generative-compression 时\n- **存储成本高昂**：为满足后续分析需求，不得不保留较大体积的原始文件或仅使用低压缩比的 JPEG，导致服务器存储费用激增。\n- **视觉伪影严重**：强行使用高压缩比的传统算法（如低码率 JPEG）后，图像出现明显的块状模糊和马赛克，难以辨认远处的交通标志或行人特征。\n- **机器识别率下降**：由于高频细节在压缩中永久丢失，下游的 AI 识别模型对压缩后的图像准确率大幅降低，需重新采集数据。\n- **传输效率低下**：大文件占用大量带宽，导致边缘设备上传数据延迟高，无法实现准实时的城市状态监控。\n\n### 使用 generative-compression 后\n- **极致压缩节省空间**：利用生成对抗网络将图像压缩至 0.072 bpp（每像素比特数），在保持感知质量的前提下，文件大小仅为传统方法的几十分之一，显著降低存储开销。\n- **感知质量“幻觉”修复**：解码器能基于学习到的语义特征“脑补”出丢失的纹理细节（如清晰的树叶、建筑轮廓），消除了传统压缩的块状伪影，肉眼观感更自然。\n- **语义特征保持完好**：虽然像素级数值有差异，但生成的图像保留了关键的语义结构，使得下游 AI 模型仍能高效提取交通流和物体信息。\n- **带宽压力骤减**：极小的文件体积让海量监控视频流能通过有限带宽快速上传，实现了低成本的城市级实时视觉数据传输。\n\ngenerative-compression 通过“以计算换带宽”的生成式重构策略，在极端低码率下实现了视觉感知与机器可读性的双重突破。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FJustin-Tan_generative-compression_0af65195.png","Justin-Tan","JTan","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FJustin-Tan_58ce8260.jpg","mostly harmless",null,"Cambridge","justin-tan.github.io\u002Fabout","https:\u002F\u002Fgithub.com\u002FJustin-Tan",[81,85],{"name":82,"color":83,"percentage":84},"Python","#3572A5",99.8,{"name":86,"color":87,"percentage":88},"Shell","#89e051",0.2,535,107,"2026-02-21T20:07:38","MIT",4,"未说明","未说明（基于 TensorFlow 1.8，通常建议使用支持 CUDA 的 NVIDIA GPU 进行训练，但 README 未明确指定型号或显存要求）",{"notes":97,"python":98,"dependencies":99},"该工具基于较旧的 TensorFlow 1.8 版本开发。预训练模型最初使用 TensorFlow 1.3 训练，但在 1.8 版本中可加载。训练数据需预处理为包含图像路径的 Pandas DataFrame 并保存为 HDF5 格式。若使用条件 GAN（cGAN）功能，还需额外下载语义标签地图数据集（如 gtFine）。配置参数主要在 config.py 中调整。","3.6",[100,101],"tensorflow==1.8","pandas",[15,14],[104,105,106,107,108],"generative-adversarial-network","image-compression","tensorflow","gan","computer-vision","2026-03-27T02:49:30.150509","2026-04-09T09:31:00.340714",[112,117,122,127,132,137],{"id":113,"question_zh":114,"answer_zh":115,"source_url":116},25918,"如何在个人数据集上进行训练？","若要在个人数据集上训练，只需执行文档中的第 3 和第 4 步。需要注意将每张图像的尺寸调整为 16 的倍数，因为编码器会从 [H, W, C] 的图像生成 H\u002F16 x W\u002F16 x C 的特征图。创建包含路径的数据框最简单的方法是使用 glob 获取文件列表，例如 `files = glob.glob(\u002Fpath\u002Fto\u002Fyour\u002Fdataset\u002F*{extension})`，然后在 Pandas 中构造 DataFrame，将单列命名为 'path'，最后使用 `df.to_hdf` 保存。","https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression\u002Fissues\u002F2",{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},25919,"如何在 ADE20K 数据集上训练模型？","是的，你需要像处理 Cityscapes 数据集一样准备数据（如生成 .h5 文件）。关于图像缩放，可以使用 ImageMagick 轻松完成。例如，将所有 PNG 图像宽度调整为 512 的命令如下：\n```bash\nfor f in .\u002F**\u002F*.png; do\n    convert $f -resize 512x $f\ndone\n```\n如果使用条件 GAN，原始图像和语义图像都需要进行相同的缩放处理。","https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression\u002Fissues\u002F8",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},25920,"可以直接使用预训练模型压缩图片吗？解码器有多大？","可以直接使用预训练模型。该模型由编码器、量化器和解码器组成，解码器是模型的一部分。解码器权重大小估计约为 100 MB。如果项目中的图片数量远大于解码器的大小（例如超过 10 倍），则在项目中直接使用是合适的。若想更深入理解压缩原理，建议阅读相关论文。","https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression\u002Fissues\u002F3",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},25921,"Cityscapes 和 ADE20K 数据集使用的语义地图（semantic map）分别是哪些文件？","对于 Cityscapes 数据集，使用的语义地图是 `*_gtFine_color.png` 文件；对于 ADE20K 数据集，使用的是 `*_seg.png` 文件。请注意，代码中尚未完全实现针对 ADE20K 的条件 GAN 部分。","https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression\u002Fissues\u002F10",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},25922,"配置较低的电脑（如 4G 内存）训练时进程被杀死（Killed）怎么办？","这通常是由于内存不足导致的。建议采取以下措施：\n1. 升级硬件或使用更高配置的机器（如 32G 内存）。\n2. 减小训练图像尺寸（例如从 512x1024 调整为 256x256）。\n3. 减少训练轮数（例如在 config.py 中将 num_epochs 从 512 改为 120）。\n此外，现在可以使用 `compress.py` 脚本来压缩图像。","https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression\u002Fissues\u002F4",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},25923,"编码器中使用 ReLU 激活函数是否会导致量化器中的负中心值（如 -2, -1）无效？","这是一个有效的观察。由于编码器末端使用了 ReLU 非线性激活，输入到量化器的特征图确实是非负的，这使得 {-2, -1} 这两个量化中心变得无用，实际熵值应小于理论上限。维护者确认这是一个问题，建议在编码器的最后一层省略 ReLU 激活函数，以便让量化边界更有意义。也可以尝试将量化中心设置为正值来验证效果。","https:\u002F\u002Fgithub.com\u002FJustin-Tan\u002Fgenerative-compression\u002Fissues\u002F23",[]]