[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-huggingface--pytorch-pretrained-BigGAN":3,"tool-huggingface--pytorch-pretrained-BigGAN":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 真正成长为懂上",160411,2,"2026-04-18T23:33:24",[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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[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},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"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":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":77,"owner_twitter":73,"owner_website":78,"owner_url":79,"languages":80,"stars":89,"forks":90,"last_commit_at":91,"license":92,"difficulty_score":32,"env_os":93,"env_gpu":94,"env_ram":93,"env_deps":95,"category_tags":102,"github_topics":103,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":111,"updated_at":112,"faqs":113,"releases":129},9413,"huggingface\u002Fpytorch-pretrained-BigGAN","pytorch-pretrained-BigGAN","🦋A PyTorch implementation of BigGAN with pretrained weights and conversion scripts.","pytorch-pretrained-BigGAN 是 DeepMind 著名 BigGAN 模型的 PyTorch 版本复现，旨在让开发者能轻松调用这一强大的图像生成工具。它核心解决了原始模型基于 TensorFlow 发布、权重难以在 PyTorch 生态中直接使用的问题，通过提供“操作对操作”的精确复现和预训练权重转换脚本，实现了与原版几乎一致的生成效果（误差极小）。\n\n该工具内置了 DeepMind 官方发布的 128x128、256x256 及 512x512 分辨率的预训练生成器模型，支持一键加载。其独特亮点在于预先计算并集成了不同截断值（truncation values）下的批归一化统计量，让用户能灵活调整生成图像的多样性与质量平衡。此外，它还提供了便捷的辅助函数，如将类别名称直接转换为向量、生成截断噪声以及快速保存或展示图像，极大简化了实验流程。\n\npytorch-pretrained-BigGAN 非常适合 AI 研究人员、深度学习开发者以及需要高质量自然图像合成能力的创作者使用。无论是用于学术探索、模型微调，还是快速构建创意视觉应用，它都能提供稳定且高效的支持，帮","pytorch-pretrained-BigGAN 是 DeepMind 著名 BigGAN 模型的 PyTorch 版本复现，旨在让开发者能轻松调用这一强大的图像生成工具。它核心解决了原始模型基于 TensorFlow 发布、权重难以在 PyTorch 生态中直接使用的问题，通过提供“操作对操作”的精确复现和预训练权重转换脚本，实现了与原版几乎一致的生成效果（误差极小）。\n\n该工具内置了 DeepMind 官方发布的 128x128、256x256 及 512x512 分辨率的预训练生成器模型，支持一键加载。其独特亮点在于预先计算并集成了不同截断值（truncation values）下的批归一化统计量，让用户能灵活调整生成图像的多样性与质量平衡。此外，它还提供了便捷的辅助函数，如将类别名称直接转换为向量、生成截断噪声以及快速保存或展示图像，极大简化了实验流程。\n\npytorch-pretrained-BigGAN 非常适合 AI 研究人员、深度学习开发者以及需要高质量自然图像合成能力的创作者使用。无论是用于学术探索、模型微调，还是快速构建创意视觉应用，它都能提供稳定且高效的支持，帮助用户无需从头训练即可享受顶尖 GAN 模型的魅力。","# PyTorch pretrained BigGAN\nAn op-for-op PyTorch reimplementation of DeepMind's BigGAN model with the pre-trained weights from DeepMind.\n\n## Introduction\n\nThis repository contains an op-for-op PyTorch reimplementation of DeepMind's BigGAN that was released with the paper [Large Scale GAN Training for High Fidelity Natural Image Synthesis](https:\u002F\u002Fopenreview.net\u002Fforum?id=B1xsqj09Fm) by Andrew Brock, Jeff Donahue and Karen Simonyan.\n\nThis PyTorch implementation of BigGAN is provided with the [pretrained 128x128, 256x256 and 512x512 models by DeepMind](https:\u002F\u002Ftfhub.dev\u002Fdeepmind\u002Fbiggan-deep-128\u002F1). We also provide the scripts used to download and convert these models from the TensorFlow Hub models.\n\nThis reimplementation was done from the raw computation graph of the Tensorflow version and behave similarly to the TensorFlow version (variance of the output difference of the order of 1e-5).\n\nThis implementation currently only contains the generator as the weights of the discriminator were not released (although the structure of the discriminator is very similar to the generator so it could be added pretty easily. Tell me if you want to do a PR on that, I would be happy to help.)\n\n## Installation\n\nThis repo was tested on Python 3.6 and PyTorch 1.0.1\n\nPyTorch pretrained BigGAN can be installed from pip as follows:\n```bash\npip install pytorch-pretrained-biggan\n```\n\nIf you simply want to play with the GAN this should be enough.\n\nIf you want to use the conversion scripts and the imagenet utilities, additional requirements are needed, in particular TensorFlow and NLTK. To install all the requirements please use the `full_requirements.txt` file:\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BigGAN.git\ncd pytorch-pretrained-BigGAN\npip install -r full_requirements.txt\n```\n\n## Models\n\nThis repository provide direct and simple access to the pretrained \"deep\" versions of BigGAN for 128, 256 and 512 pixels resolutions as described in the [associated publication](https:\u002F\u002Fopenreview.net\u002Fforum?id=B1xsqj09Fm).\nHere are some details on the models:\n\n- `BigGAN-deep-128`: a 50.4M parameters model generating 128x128 pixels images, the model dump weights 201 MB,\n- `BigGAN-deep-256`: a 55.9M parameters model generating 256x256 pixels images, the model dump weights 224 MB,\n- `BigGAN-deep-512`: a 56.2M parameters model generating 512x512 pixels images, the model dump weights 225 MB.\n\nPlease refer to Appendix B of the paper for details on the architectures.\n\nAll models comprise pre-computed batch norm statistics for 51 truncation values between 0 and 1 (see Appendix C.1 in the paper for details).\n\n## Usage\n\nHere is a quick-start example using `BigGAN` with a pre-trained model.\n\nSee the [doc section](#doc) below for details on these classes and methods.\n\n```python\nimport torch\nfrom pytorch_pretrained_biggan import (BigGAN, one_hot_from_names, truncated_noise_sample,\n                                       save_as_images, display_in_terminal)\n\n# OPTIONAL: if you want to have more information on what's happening, activate the logger as follows\nimport logging\nlogging.basicConfig(level=logging.INFO)\n\n# Load pre-trained model tokenizer (vocabulary)\nmodel = BigGAN.from_pretrained('biggan-deep-256')\n\n# Prepare a input\ntruncation = 0.4\nclass_vector = one_hot_from_names(['soap bubble', 'coffee', 'mushroom'], batch_size=3)\nnoise_vector = truncated_noise_sample(truncation=truncation, batch_size=3)\n\n# All in tensors\nnoise_vector = torch.from_numpy(noise_vector)\nclass_vector = torch.from_numpy(class_vector)\n\n# If you have a GPU, put everything on cuda\nnoise_vector = noise_vector.to('cuda')\nclass_vector = class_vector.to('cuda')\nmodel.to('cuda')\n\n# Generate an image\nwith torch.no_grad():\n    output = model(noise_vector, class_vector, truncation)\n\n# If you have a GPU put back on CPU\noutput = output.to('cpu')\n\n# If you have a sixtel compatible terminal you can display the images in the terminal\n# (see https:\u002F\u002Fgithub.com\u002Fsaitoha\u002Flibsixel for details)\ndisplay_in_terminal(output)\n\n# Save results as png images\nsave_as_images(output)\n```\n\n![output_0](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_readme_103ddc8fbb50.png)\n![output_1](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_readme_e6a26cc4957b.png)\n![output_2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_readme_4bc8b6b20524.png)\n\n## Doc\n\n### Loading DeepMind's pre-trained weights\n\nTo load one of DeepMind's pre-trained models, instantiate a `BigGAN` model with `from_pretrained()` as:\n\n```python\nmodel = BigGAN.from_pretrained(PRE_TRAINED_MODEL_NAME_OR_PATH, cache_dir=None)\n```\n\nwhere\n\n- `PRE_TRAINED_MODEL_NAME_OR_PATH` is either:\n\n  - the shortcut name of a Google AI's or OpenAI's pre-trained model selected in the list:\n\n    - `biggan-deep-128`: 12-layer, 768-hidden, 12-heads, 110M parameters\n    - `biggan-deep-256`: 24-layer, 1024-hidden, 16-heads, 340M parameters\n    - `biggan-deep-512`: 12-layer, 768-hidden, 12-heads , 110M parameters\n\n  - a path or url to a pretrained model archive containing:\n\n    - `config.json`: a configuration file for the model, and\n    - `pytorch_model.bin` a PyTorch dump of a pre-trained instance of `BigGAN` (saved with the usual `torch.save()`).\n\n  If `PRE_TRAINED_MODEL_NAME_OR_PATH` is a shortcut name, the pre-trained weights will be downloaded from AWS S3 (see the links [here](pytorch_pretrained_biggan\u002Fmodel.py)) and stored in a cache folder to avoid future download (the cache folder can be found at `~\u002F.pytorch_pretrained_biggan\u002F`).\n- `cache_dir` can be an optional path to a specific directory to download and cache the pre-trained model weights.\n\n### Configuration\n\n`BigGANConfig` is a class to store and load BigGAN configurations. It's defined in [`config.py`](.\u002Fpytorch_pretrained_biggan\u002Fconfig.py).\n\nHere are some details on the attributes:\n\n- `output_dim`: output resolution of the GAN (128, 256 or 512) for the pre-trained models,\n- `z_dim`: size of the noise vector (128 for the pre-trained models).\n- `class_embed_dim`: size of the class embedding vectors (128 for the pre-trained models).\n- `channel_width`: size of each channel (128 for the pre-trained models).\n- `num_classes`: number of classes in the training dataset, like imagenet (1000 for the pre-trained models).\n- `layers`: A list of layers definition. Each definition for a layer is a triple of [up-sample in the layer ? (bool), number of input channels (int), number of output channels (int)]\n- `attention_layer_position`: Position of the self-attention layer in the layer hierarchy (8 for the pre-trained models).\n- `eps`: epsilon value to use for spectral and batch normalization layers (1e-4 for the pre-trained models).\n- `n_stats`: number of pre-computed statistics for the batch normalization layers associated to various truncation values between 0 and 1 (51 for the pre-trained models).\n\n### Model\n\n`BigGAN` is a PyTorch model (`torch.nn.Module`) of BigGAN defined in [`model.py`](.\u002Fpytorch_pretrained_biggan\u002Fmodel.py). This model comprises the class embeddings (a linear layer) and the generator with a series of convolutions and conditional batch norms. The discriminator is currently not implemented since pre-trained weights have not been released for it.\n\nThe inputs and output are **identical to the TensorFlow model inputs and outputs**.\n\nWe detail them here.\n\n`BigGAN` takes as *inputs*:\n\n- `z`: a torch.FloatTensor of shape [batch_size, config.z_dim] with noise sampled from a truncated normal distribution, and\n- `class_label`: an optional torch.LongTensor of shape [batch_size, sequence_length] with the token types indices selected in [0, 1]. Type 0 corresponds to a `sentence A` and type 1 corresponds to a `sentence B` token (see BERT paper for more details).\n- `truncation`: a float between 0 (not comprised) and 1. The truncation of the truncated normal used for creating the noise vector. This truncation value is used to selecte between a set of pre-computed statistics (means and variances) for the batch norm layers.\n\n`BigGAN` *outputs* an array of shape [batch_size, 3, resolution, resolution] where resolution is 128, 256 or 512 depending of the model:\n\n### Utilities: Images, Noise, Imagenet classes\n\nWe provide a few utility method to use the model. They are defined in [`utils.py`](.\u002Fpytorch_pretrained_biggan\u002Futils.py).\n\nHere are some details on these methods:\n\n- `truncated_noise_sample(batch_size=1, dim_z=128, truncation=1., seed=None)`:\n\n    Create a truncated noise vector.\n    - Params:\n        - batch_size: batch size.\n        - dim_z: dimension of z\n        - truncation: truncation value to use\n        - seed: seed for the random generator\n    - Output:\n        array of shape (batch_size, dim_z)\n\n- `convert_to_images(obj)`:\n\n    Convert an output tensor from BigGAN in a list of images.\n    - Params:\n        - obj: tensor or numpy array of shape (batch_size, channels, height, width)\n    - Output:\n        - list of Pillow Images of size (height, width)\n\n- `save_as_images(obj, file_name='output')`:\n\n    Convert and save an output tensor from BigGAN in a list of saved images.\n    - Params:\n        - obj: tensor or numpy array of shape (batch_size, channels, height, width)\n        - file_name: path and beggingin of filename to save.\n            Images will be saved as `file_name_{image_number}.png`\n\n- `display_in_terminal(obj)`:\n\n    Convert and display an output tensor from BigGAN in the terminal. This function use `libsixel` and will only work in a libsixel-compatible terminal. Please refer to https:\u002F\u002Fgithub.com\u002Fsaitoha\u002Flibsixel for more details.\n    - Params:\n        - obj: tensor or numpy array of shape (batch_size, channels, height, width)\n        - file_name: path and beggingin of filename to save.\n            Images will be saved as `file_name_{image_number}.png`\n\n- `one_hot_from_int(int_or_list, batch_size=1)`:\n\n    Create a one-hot vector from a class index or a list of class indices.\n    - Params:\n        - int_or_list: int, or list of int, of the imagenet classes (between 0 and 999)\n        - batch_size: batch size.\n            - If int_or_list is an int create a batch of identical classes.\n            - If int_or_list is a list, we should have `len(int_or_list) == batch_size`\n    - Output:\n        - array of shape (batch_size, 1000)\n\n- `one_hot_from_names(class_name, batch_size=1)`:\n\n    Create a one-hot vector from the name of an imagenet class ('tennis ball', 'daisy', ...). We use NLTK's wordnet search to try to find the relevant synset of ImageNet and take the first one. If we can't find it direcly, we look at the hyponyms and hypernyms of the class name.\n    - Params:\n        - class_name: string containing the name of an imagenet object.\n    - Output:\n        - array of shape (batch_size, 1000)\n\n## Download and conversion scripts\n\nScripts to download and convert the TensorFlow models from TensorFlow Hub are provided in [.\u002Fscripts](.\u002Fscripts\u002F).\n\nThe scripts can be used directly as:\n```bash\n.\u002Fscripts\u002Fdownload_tf_hub_models.sh\n.\u002Fscripts\u002Fconvert_tf_hub_models.sh\n```\n","# PyTorch 预训练 BigGAN\n基于 DeepMind 的 BigGAN 模型，并附带 DeepMind 提供的预训练权重，以操作对操作的方式在 PyTorch 中重新实现。\n\n## 简介\n\n本仓库包含 DeepMind 在论文《用于高保真自然图像合成的大规模 GAN 训练》（作者：Andrew Brock、Jeff Donahue 和 Karen Simonyan）中发布的 BigGAN 的 PyTorch 版本，该版本实现了与 TensorFlow 原版相同的操作逻辑。\n\n此 PyTorch 实现附带了 DeepMind 提供的 [128x128、256x256 和 512x512 分辨率的预训练模型](https:\u002F\u002Ftfhub.dev\u002Fdeepmind\u002Fbiggan-deep-128\u002F1)。我们还提供了用于从 TensorFlow Hub 下载并转换这些模型的脚本。\n\n该重实现基于 TensorFlow 版本的原始计算图完成，其行为与 TensorFlow 版本高度一致，输出差异的数量级约为 1e-5。\n\n目前，该实现仅包含生成器部分，因为判别器的权重并未公开（尽管判别器的结构与生成器非常相似，因此可以很容易地添加）。如果您希望为此提交 PR，我将非常乐意提供帮助。\n\n## 安装\n\n本仓库已在 Python 3.6 和 PyTorch 1.0.1 上测试通过。\n\n可以通过 pip 安装 PyTorch 预训练 BigGAN：\n\n```bash\npip install pytorch-pretrained-biggan\n```\n\n如果您只是想简单体验一下这个 GAN，那么以上安装步骤就足够了。\n\n如果您还想使用转换脚本和 ImageNet 工具，则需要额外的依赖，尤其是 TensorFlow 和 NLTK。要安装所有依赖，请使用 `full_requirements.txt` 文件：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BigGAN.git\ncd pytorch-pretrained-BigGAN\npip install -r full_requirements.txt\n```\n\n## 模型\n\n本仓库提供了对 BigGAN “deep” 版本的直接且简便访问，支持 128、256 和 512 像素分辨率，具体如[相关论文](https:\u002F\u002Fopenreview.net\u002Fforum?id=B1xsqj09Fm)所述。以下是各模型的详细信息：\n\n- `BigGAN-deep-128`：一个拥有 5040 万参数、生成 128x128 像素图像的模型，模型文件大小为 201 MB；\n- `BigGAN-deep-256`：一个拥有 5590 万参数、生成 256x256 像素图像的模型，模型文件大小为 224 MB；\n- `BigGAN-deep-512`：一个拥有 5620 万参数、生成 512x512 像素图像的模型，模型文件大小为 225 MB。\n\n有关架构的详细信息，请参阅论文的附录 B。\n\n所有模型都预先计算好了 51 种截断值（范围从 0 到 1）对应的批量归一化统计信息，详情请参阅论文附录 C.1。\n\n## 使用\n\n以下是一个使用预训练模型的 `BigGAN` 快速入门示例。\n\n有关这些类和方法的详细信息，请参阅下方的 [文档部分](#doc)。\n\n```python\nimport torch\nfrom pytorch_pretrained_biggan import (BigGAN, one_hot_from_names, truncated_noise_sample,\n                                       save_as_images, display_in_terminal)\n\n# 可选：如果想了解更多信息，可以启用日志记录\nimport logging\nlogging.basicConfig(level=logging.INFO)\n\n# 加载预训练模型分词器（词汇表）\nmodel = BigGAN.from_pretrained('biggan-deep-256')\n\n# 准备输入\ntruncation = 0.4\nclass_vector = one_hot_from_names(['肥皂泡', '咖啡', '蘑菇'], batch_size=3)\nnoise_vector = truncated_noise_sample(truncation=truncation, batch_size=3)\n\n# 将所有数据转换为张量\nnoise_vector = torch.from_numpy(noise_vector)\nclass_vector = torch.from_numpy(class_vector)\n\n# 如果有 GPU，将所有数据转移到 CUDA 上\nnoise_vector = noise_vector.to('cuda')\nclass_vector = class_vector.to('cuda')\nmodel.to('cuda')\n\n# 生成图像\nwith torch.no_grad():\n    output = model(noise_vector, class_vector, truncation)\n\n# 如果有 GPU，再将结果移回 CPU\noutput = output.to('cpu')\n\n# 如果终端支持 sixel 格式，可以直接在终端中显示图像\n# （详情请参见 https:\u002F\u002Fgithub.com\u002Fsaitoha\u002Flibsixel）\ndisplay_in_terminal(output)\n\n# 将结果保存为 PNG 图像\nsave_as_images(output)\n```\n\n![output_0](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_readme_103ddc8fbb50.png)\n![output_1](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_readme_e6a26cc4957b.png)\n![output_2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_readme_4bc8b6b20524.png)\n\n## 文档\n\n### 加载 DeepMind 的预训练权重\n\n要加载 DeepMind 的预训练模型之一，可以使用 `from_pretrained()` 方法实例化一个 `BigGAN` 模型，如下所示：\n\n```python\nmodel = BigGAN.from_pretrained(PRE_TRAINED_MODEL_NAME_OR_PATH, cache_dir=None)\n```\n\n其中：\n\n- `PRE_TRAINED_MODEL_NAME_OR_PATH` 可以是以下两种形式之一：\n  - Google AI 或 OpenAI 提供的预训练模型的快捷名称，可从以下列表中选择：\n    - `biggan-deep-128`：12 层，768 隐藏单元，12 头注意力机制，1.1 亿参数；\n    - `biggan-deep-256`：24 层，1024 隐藏单元，16 头注意力机制，3.4 亿参数；\n    - `biggan-deep-512`：12 层，768 隐藏单元，12 头注意力机制，1.1 亿参数。\n  - 预训练模型存档的路径或 URL，其中包含：\n    - `config.json`：模型配置文件；\n    - `pytorch_model.bin`：`BigGAN` 预训练实例的 PyTorch 模型文件（使用常规的 `torch.save()` 保存）。\n  如果 `PRE_TRAINED_MODEL_NAME_OR_PATH` 是快捷名称，预训练权重将从 AWS S3 下载（详见 [此处](pytorch_pretrained_biggan\u002Fmodel.py) 的链接），并存储在缓存目录中以避免重复下载（默认缓存目录为 `~\u002F.pytorch_pretrained_biggan\u002F`）。\n- `cache_dir` 是一个可选参数，用于指定下载和缓存预训练模型权重的具体目录。\n\n### 配置\n\n`BigGANConfig` 是一个用于存储和加载 BigGAN 配置的类，定义于 [`config.py`](.\u002Fpytorch_pretrained_biggan\u002Fconfig.py) 中。\n\n以下是该类的一些属性说明：\n\n- `output_dim`：GAN 的输出分辨率（128、256 或 512），适用于预训练模型；\n- `z_dim`：噪声向量的维度（128，适用于预训练模型）；\n- `class_embed_dim`：类别嵌入向量的维度（128，适用于预训练模型）；\n- `channel_width`：每个通道的宽度（128，适用于预训练模型）；\n- `num_classes`：训练数据集中的类别数量，例如 ImageNet（1000 类，适用于预训练模型）；\n- `layers`：层定义列表。每项定义由三元组组成：[是否为上采样层？（布尔值）、输入通道数（整数）、输出通道数（整数）]；\n- `attention_layer_position`：自注意力层在层结构中的位置（适用于预训练模型，为第 8 层）；\n- `eps`：用于谱归一化和批量归一化层的 ε 值（适用于预训练模型，为 1e-4）；\n- `n_stats`：与不同截断值（0 到 1）相关的批量归一化层的预计算统计数量（适用于预训练模型，为 51）。\n\n### 模型\n\n`BigGAN` 是一个 PyTorch 模型（`torch.nn.Module`），其定义位于 [`model.py`](.\u002Fpytorch_pretrained_biggan\u002Fmodel.py) 中。该模型由类别嵌入（一个线性层）和包含一系列卷积及条件批归一化的生成器组成。目前尚未实现判别器，因为其预训练权重尚未公开。\n\n输入和输出与 TensorFlow 模型的输入和输出完全一致。\n\n我们在此详细说明它们。\n\n`BigGAN` 的 *输入* 包括：\n\n- `z`：形状为 `[batch_size, config.z_dim]` 的 `torch.FloatTensor`，其中噪声是从截断正态分布中采样的；\n- `class_label`：可选的 `torch.LongTensor`，形状为 `[batch_size, sequence_length]`，包含从 `[0, 1]` 中选择的标记类型索引。类型 0 对应于“句子 A”，类型 1 对应于“句子 B”标记（更多详情请参阅 BERT 论文）；\n- `truncation`：一个介于 0（不包括）和 1 之间的浮点数，用于控制生成噪声向量时所用截断正态分布的截断程度。此截断值用于在预计算好的批归一化层统计量（均值和方差）集合中进行选择。\n\n`BigGAN` 的 *输出* 是一个形状为 `[batch_size, 3, resolution, resolution]` 的张量，其中分辨率根据模型的不同可以是 128、256 或 512。\n\n### 工具：图像、噪声、ImageNet 类别\n\n我们提供了一些用于使用该模型的实用方法，这些方法定义在 [`utils.py`](.\u002Fpytorch_pretrained_biggan\u002Futils.py) 中。\n\n以下是这些方法的详细信息：\n\n- `truncated_noise_sample(batch_size=1, dim_z=128, truncation=1., seed=None)`：\n\n    创建一个截断噪声向量。\n    - 参数：\n        - batch_size：批次大小。\n        - dim_z：z 的维度。\n        - truncation：使用的截断值。\n        - seed：随机数生成器的种子。\n    - 输出：\n        形状为 `(batch_size, dim_z)` 的数组。\n\n- `convert_to_images(obj)`：\n\n    将 BigGAN 的输出张量转换为图像列表。\n    - 参数：\n        - obj：形状为 `(batch_size, channels, height, width)` 的张量或 NumPy 数组。\n    - 输出：\n        - 大小为 `(height, width)` 的 Pillow 图像列表。\n\n- `save_as_images(obj, file_name='output')`：\n\n    将 BigGAN 的输出张量转换并保存为一系列图像文件。\n    - 参数：\n        - obj：形状为 `(batch_size, channels, height, width)` 的张量或 NumPy 数组。\n        - file_name：保存路径及文件名前缀。图像将被保存为 `file_name_{image_number}.png`。\n    \n- `display_in_terminal(obj)`：\n\n    将 BigGAN 的输出张量转换并在终端中显示。此函数使用 `libsixel` 库，仅能在支持 `libsixel` 的终端中运行。更多信息请参阅 https:\u002F\u002Fgithub.com\u002Fsaitoha\u002Flibsixel。\n    - 参数：\n        - obj：形状为 `(batch_size, channels, height, width)` 的张量或 NumPy 数组。\n        - file_name：保存路径及文件名前缀。图像将被保存为 `file_name_{image_number}.png`。\n\n- `one_hot_from_int(int_or_list, batch_size=1)`：\n\n    根据类别索引或类别索引列表创建独热编码向量。\n    - 参数：\n        - int_or_list：ImageNet 类别的整数，或整数列表（范围在 0 到 999 之间）。\n        - batch_size：批次大小。\n            - 如果 `int_or_list` 是一个整数，则生成一批相同的类别。\n            - 如果 `int_or_list` 是一个列表，则应满足 `len(int_or_list) == batch_size`。\n    - 输出：\n        形状为 `(batch_size, 1000)` 的数组。\n\n- `one_hot_from_names(class_name, batch_size=1)`：\n\n    根据 ImageNet 类别的名称（如“网球”、“雏菊”等）创建独热编码向量。我们使用 NLTK 的 WordNet 搜索来尝试找到对应的 ImageNet 同义词集，并取第一个结果。如果无法直接找到，则会查找该类别的下位词和上位词。\n    - 参数：\n        - class_name：包含 ImageNet 物体名称的字符串。\n    - 输出：\n        形状为 `(batch_size, 1000)` 的数组。\n\n## 下载和转换脚本\n\n用于从 TensorFlow Hub 下载并转换 TensorFlow 模型的脚本位于 [.\u002Fscripts](.\u002Fscripts\u002F) 中。\n\n这些脚本可以直接使用，命令如下：\n```bash\n.\u002Fscripts\u002Fdownload_tf_hub_models.sh\n.\u002Fscripts\u002Fconvert_tf_hub_models.sh\n```","# PyTorch Pretrained BigGAN 快速上手指南\n\n本指南帮助开发者快速在 PyTorch 环境中使用 DeepMind 的 BigGAN 预训练模型，生成高分辨率自然图像。\n\n## 环境准备\n\n- **操作系统**：Linux \u002F macOS \u002F Windows\n- **Python 版本**：推荐 Python 3.6+\n- **核心依赖**：\n  - PyTorch >= 1.0.1\n  - torchvision\n- **可选依赖**（如需使用模型转换脚本或 ImageNet 工具）：\n  - TensorFlow\n  - NLTK\n  - libsixel（用于终端显示图像）\n\n> 💡 提示：国内用户可使用清华或阿里镜像源加速 PyTorch 安装：\n> ```bash\n> pip install torch torchvision -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n> ```\n\n## 安装步骤\n\n### 方式一：仅使用生成模型（推荐）\n\n若只需加载预训练模型进行图像生成，直接通过 pip 安装即可：\n\n```bash\npip install pytorch-pretrained-biggan\n```\n\n### 方式二：完整功能安装（含转换脚本与工具）\n\n如需下载并转换 TensorFlow Hub 上的原始模型，或使用 ImageNet 类别名称查询等功能，请克隆仓库并安装全部依赖：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BigGAN.git\ncd pytorch-pretrained-BigGAN\npip install -r full_requirements.txt\n```\n\n> 💡 国内用户可考虑使用 Gitee 镜像加速克隆（如有）：\n> ```bash\n> git clone https:\u002F\u002Fgitee.com\u002Fmirror\u002Fpytorch-pretrained-BigGAN.git\n> ```\n\n## 基本使用\n\n以下是最小可用示例，加载 `biggan-deep-256` 模型并生成三张图像（肥皂泡、咖啡、蘑菇）：\n\n```python\nimport torch\nfrom pytorch_pretrained_biggan import (BigGAN, one_hot_from_names, truncated_noise_sample,\n                                       save_as_images)\n\n# 可选：开启日志查看详细加载过程\nimport logging\nlogging.basicConfig(level=logging.INFO)\n\n# 加载预训练模型（自动下载并缓存）\nmodel = BigGAN.from_pretrained('biggan-deep-256')\n\n# 设置截断值（控制多样性与质量平衡）\ntruncation = 0.4\n\n# 准备类别向量（支持英文 ImageNet 类别名）\nclass_vector = one_hot_from_names(['soap bubble', 'coffee', 'mushroom'], batch_size=3)\n\n# 生成截断噪声向量\nnoise_vector = truncated_noise_sample(truncation=truncation, batch_size=3)\n\n# 转为 Tensor 并移至 GPU（如有）\nnoise_vector = torch.from_numpy(noise_vector).to('cuda' if torch.cuda.is_available() else 'cpu')\nclass_vector = torch.from_numpy(class_vector).to('cuda' if torch.cuda.is_available() else 'cpu')\nmodel.to('cuda' if torch.cuda.is_available() else 'cpu')\n\n# 生成图像\nwith torch.no_grad():\n    output = model(noise_vector, class_vector, truncation)\n\n# 保存为 PNG 图片\nsave_as_images(output.to('cpu'), file_name='my_biggen_output')\n```\n\n运行后将生成 `my_biggen_output_0.png`、`my_biggen_output_1.png`、`my_biggen_output_2.png` 三张 256x256 分辨率的高质量图像。\n\n> 📌 可用类别名参考 ImageNet 数据集，如 `'tennis ball'`, `'daisy'`, `'goldfish'` 等。","一位数字艺术创作者需要快速生成一系列高分辨率、特定主题（如“肥皂泡”、“咖啡”、“蘑菇”）的超现实素材用于概念设计。\n\n### 没有 pytorch-pretrained-BigGAN 时\n- **环境配置极其繁琐**：开发者必须手动搭建 TensorFlow 环境，寻找并下载 DeepMind 原始的权重文件，再编写复杂的转换脚本将其转为 PyTorch 格式，极易因版本兼容问题失败。\n- **复现门槛高**：BigGAN 架构复杂，从零实现或微调模型需要深厚的深度学习功底，普通开发者难以在短期内跑通代码。\n- **生成控制困难**：缺乏现成的工具来处理截断技巧（truncation trick）和类别向量映射，导致生成的图像质量不稳定或无法精准控制主题。\n- **硬件适配耗时**：原始代码对 GPU 加速的支持不够友好，需要大量手动修改才能在实际开发中高效运行。\n\n### 使用 pytorch-pretrained-BigGAN 后\n- **一键加载预训练模型**：通过 `BigGAN.from_pretrained` 即可直接调用官方提供的 128 至 512 分辨率高质量模型，彻底省去了环境配置和权重转换的痛苦。\n- **极简 API 调用**：仅需几行代码即可完成从噪声采样、类别指定（如 `one_hot_from_names`）到图像生成的全流程，大幅降低技术门槛。\n- **精准可控的输出**：内置了预计算的批量归一化统计量和截断采样功能，开发者可轻松调节参数，稳定生成符合预期的高保真图像。\n- **原生 PyTorch 支持**：作为原生 PyTorch 实现，无缝集成现有的 GPU 工作流，推理速度与原版 TensorFlow 几乎一致且更易于调试。\n\npytorch-pretrained-BigGAN 将原本需要数天配置的复杂生成式 AI 任务，简化为几分钟内即可完成的创意实验，极大释放了开发者的生产力。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_pytorch-pretrained-BigGAN_b0cfbf04.png","huggingface","Hugging Face","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fhuggingface_90da21a4.png","The AI community building the future.",null,"https:\u002F\u002Fhuggingface.co\u002F","https:\u002F\u002Fgithub.com\u002Fhuggingface",[81,85],{"name":82,"color":83,"percentage":84},"Python","#3572A5",98.5,{"name":86,"color":87,"percentage":88},"Shell","#89e051",1.5,1043,178,"2026-04-05T16:26:34","MIT","未说明","非必需，但示例代码支持 CUDA；具体型号和显存大小取决于生成的图像分辨率（128\u002F256\u002F512），未明确说明最低要求",{"notes":96,"python":97,"dependencies":98},"该工具是 DeepMind BigGAN 的 PyTorch 复现版，仅包含生成器（判别器权重未发布）。基础安装仅需 PyTorch，若需使用模型转换脚本和 ImageNet 工具则需额外安装 TensorFlow 和 NLTK。预训练模型权重会自动从 AWS S3 下载并缓存，提供 128、256 和 512 三种分辨率模型。终端显示图片功能需要 libsixel 兼容环境。","3.6",[99,100,101],"torch==1.0.1","tensorflow","nltk",[14,15],[104,105,106,107,108,109,110],"neural-network","gan","pytorch","biggan","computer-vision","artificial-intelligence","generative-adversarial-network","2026-03-27T02:49:30.150509","2026-04-19T09:15:05.122205",[114,119,124],{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},42255,"加载模型时出现 TypeError: 'encoding' is an invalid keyword argument for this function 错误怎么办？","这是因为代码使用了 Python 3 特有的 open() 函数 encoding 参数，而您正在使用 Python 2.7。解决方案是使用 Python 3 运行脚本，命令为：python3 visualize.py（或将默认 python 指向 python3）。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BigGAN\u002Fissues\u002F12",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},42256,"生成的图像与 TensorFlow 官方实现的结果不一致，如何解决？","请确认您使用的模型版本。该仓库提供的是 BigGAN-deep 模型，而非标准的 BigGAN 模型。如果您尝试将其与标准 BigGAN 的 TensorFlow 结果进行对比，会出现显著差异。请重新针对 BigGAN-deep 版本进行匹配测试。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BigGAN\u002Fissues\u002F3",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},42257,"在中国下载预训练模型速度很慢，有国内镜像源吗？","目前仓库尚未在文件缓存工具中自动集成镜像逻辑。建议查看项目的 README 文档，维护者可能会在那里提供备用的下载链接以加速访问。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-pretrained-BigGAN\u002Fissues\u002F4",[130,135],{"id":131,"version":132,"summary_zh":133,"released_at":134},334377,"v0.1.1","新增在终端显示多张图像的功能，并为一批多个类别生成 one-hot 向量。","2019-03-21T13:56:08",{"id":136,"version":137,"summary_zh":138,"released_at":139},334378,"v0.1.0","这是 `pytorch-pretrained-bigggan` 的首个版本。","2019-03-21T13:16:09"]