[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-EndlessSora--focal-frequency-loss":3,"tool-EndlessSora--focal-frequency-loss":62},[4,18,26,35,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},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"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",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"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",[52,15,13,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},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"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":78,"owner_email":79,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":92,"forks":93,"last_commit_at":94,"license":95,"difficulty_score":96,"env_os":97,"env_gpu":98,"env_ram":97,"env_deps":99,"category_tags":104,"github_topics":105,"view_count":32,"oss_zip_url":79,"oss_zip_packed_at":79,"status":17,"created_at":124,"updated_at":125,"faqs":126,"releases":162},7975,"EndlessSora\u002Ffocal-frequency-loss","focal-frequency-loss","[ICCV 2021] Focal Frequency Loss for Image Reconstruction and Synthesis","focal-frequency-loss 是一款专为图像重建与合成任务设计的 PyTorch 损失函数库，源自 ICCV 2021 的研究成果。在生成模型日益强大的今天，生成图像与真实图像之间往往仍存在细微差距，尤其是在频率域信息上容易丢失细节，导致画面模糊或纹理不自然。focal-frequency-loss 通过引入“焦点频率损失”机制，能够自适应地关注那些难以合成的频率成分，同时降低易合成部分的权重，从而有效弥补神经网络固有的偏差，显著提升图像的感知质量和定量指标。\n\n该工具特别适用于从事计算机视觉研究的科研人员、深度学习开发者以及需要优化图像生成效果的算法工程师。它可以无缝集成到 VAE、pix2pix、SPADE 乃至 StyleGAN2 等主流模型中，作为现有空间损失函数的有力补充。其核心亮点在于灵活的频谱权重矩阵设计，用户仅需调整 `loss_weight` 和 `alpha` 等少量超参数，即可让模型更专注于修复高频细节。安装简便，几行代码即可调用，是提升图像生成细腻度与真实感的实用利器。","## Focal Frequency Loss - Official PyTorch Implementation\n\n![teaser](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_7884f318c1e4.jpg)\n\nThis repository provides the official PyTorch implementation for the following paper:\n\n**Focal Frequency Loss for Image Reconstruction and Synthesis**\u003Cbr>\n[Liming Jiang](https:\u002F\u002Fliming-jiang.com\u002F), [Bo Dai](http:\u002F\u002Fdaibo.info\u002F), [Wayne Wu](https:\u002F\u002Fwywu.github.io\u002F) and [Chen Change Loy](http:\u002F\u002Fpersonal.ie.cuhk.edu.hk\u002F~ccloy\u002F)\u003Cbr>\nIn ICCV 2021.\u003Cbr>\n[**Project Page**](https:\u002F\u002Fwww.mmlab-ntu.com\u002Fproject\u002Fffl\u002Findex.html) | [**Paper**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.12821) | [**Poster**](https:\u002F\u002Fliming-jiang.com\u002Fprojects\u002FFFL\u002Fresources\u002Fposter.pdf) | [**Slides**](https:\u002F\u002Fliming-jiang.com\u002Fprojects\u002FFFL\u002Fresources\u002Fslides.pdf) | [**YouTube Demo**](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=RNTnDtKvcpc)\n> **Abstract:** *Image reconstruction and synthesis have witnessed remarkable progress thanks to the development of generative models. Nonetheless, gaps could still exist between the real and generated images, especially in the frequency domain. In this study, we show that narrowing gaps in the frequency domain can ameliorate image reconstruction and synthesis quality further. We propose a novel focal frequency loss, which allows a model to adaptively focus on frequency components that are hard to synthesize by down-weighting the easy ones. This objective function is complementary to existing spatial losses, offering great impedance against the loss of important frequency information due to the inherent bias of neural networks. We demonstrate the versatility and effectiveness of focal frequency loss to improve popular models, such as VAE, pix2pix, and SPADE, in both perceptual quality and quantitative performance. We further show its potential on StyleGAN2.*\n\n## Updates\n\n- [09\u002F2021] The **code** of Focal Frequency Loss is **released**.\n\n- [07\u002F2021] The [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.12821) of Focal Frequency Loss is accepted by **ICCV 2021**.\n\n## Quick Start\n\nRun `pip install focal-frequency-loss` for installation. Then, the following code is all you need.\n\n```python\nfrom focal_frequency_loss import FocalFrequencyLoss as FFL\nffl = FFL(loss_weight=1.0, alpha=1.0)  # initialize nn.Module class\n\nimport torch\nfake = torch.randn(4, 3, 64, 64)  # replace it with the predicted tensor of shape (N, C, H, W)\nreal = torch.randn(4, 3, 64, 64)  # replace it with the target tensor of shape (N, C, H, W)\n\nloss = ffl(fake, real)  # calculate focal frequency loss\n```\n\n**Tips:** \n\n1. Current supported PyTorch version: `torch>=1.1.0`. Warnings can be ignored. Please note that experiments in the paper were conducted with `torch\u003C=1.7.1,>=1.1.0`.\n2. Arguments to initialize the `FocalFrequencyLoss` class:\n\t- `loss_weight (float)`: weight for focal frequency loss. Default: 1.0\n\t- `alpha (float)`: the scaling factor alpha of the spectrum weight matrix for flexibility. Default: 1.0\n\t- `patch_factor (int)`: the factor to crop image patches for patch-based focal frequency loss. Default: 1\n\t- `ave_spectrum (bool)`: whether to use minibatch average spectrum. Default: False\n\t- `log_matrix (bool)`: whether to adjust the spectrum weight matrix by logarithm. Default: False\n\t- `batch_matrix (bool)`: whether to calculate the spectrum weight matrix using batch-based statistics. Default: False\n3. Experience shows that the main hyperparameters you need to adjust are `loss_weight` and `alpha`. The loss weight may always need to be adjusted first. Then, a larger alpha indicates that the model is more focused. We use `alpha=1.0` as default.\n\n## Exmaple: Image Reconstruction (Vanilla AE)\n\nAs a guide, we provide an example of applying the proposed focal frequency loss (FFL) for Vanilla AE image reconstruction on CelebA. Applying FFL is pretty easy. The core details can be found [here](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fblob\u002Fmaster\u002FVanillaAE\u002Fmodels.py).\n\n### Installation\n\nAfter installing [Anaconda](https:\u002F\u002Fwww.anaconda.com\u002F), we recommend you to create a new conda environment with python 3.8.3:\n\n```bash\nconda create -n ffl python=3.8.3 -y\nconda activate ffl\n```\n\nClone this repo, install PyTorch 1.4.0 (`torch>=1.1.0` may also work) and other dependencies:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss.git\ncd focal-frequency-loss\npip install -r VanillaAE\u002Frequirements.txt\n```\n\n### Dataset Preparation\n\nIn this example, please download [img\\_align\\_celeba.zip](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F0B7EVK8r0v71pZjFTYXZWM3FlRnM\u002Fview?usp=sharing&resourcekey=0-dYn9z10tMJOBAkviAcfdyQ) of the CelebA dataset from its [official website](https:\u002F\u002Fmmlab.ie.cuhk.edu.hk\u002Fprojects\u002FCelebA.html). Then, we highly recommend you to unzip this file and symlink the `img_align_celeba` folder to `.\u002Fdatasets\u002Fceleba` by:\n\n```bash\nbash scripts\u002Fdatasets\u002Fprepare_celeba.sh [PATH_TO_IMG_ALIGN_CELEBA]\n```\n\nOr you can simply move the `img_align_celeba` folder to `.\u002Fdatasets\u002Fceleba`. The resulting directory structure should be:\n\n```\n├── datasets\n│    ├── celeba\n│    │    ├── img_align_celeba  \n│    │    │    ├── 000001.jpg\n│    │    │    ├── 000002.jpg\n│    │    │    ├── 000003.jpg\n│    │    │    ├── ...\n```\n\n### Test and Evaluation Metrics\n\nDownload the [pretrained models](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1YIH09eoDyP2JLmiYJpju4hOkVFO7M3b_\u002Fview?usp=sharing) and unzip them to `.\u002FVanillaAE\u002Fexperiments`.\n\nWe have provided the example [test scripts](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fscripts\u002FVanillaAE\u002Ftest). If you only have a CPU environment, please specify `--no_cuda` in the script. Run:\n\n```bash\nbash scripts\u002FVanillaAE\u002Ftest\u002Fceleba_recon_wo_ffl.sh\nbash scripts\u002FVanillaAE\u002Ftest\u002Fceleba_recon_w_ffl.sh\n```\n\nThe Vanilla AE image reconstruction results will be saved at `.\u002FVanillaAE\u002Fresults` by default.\n\nAfter testing, you can further calculate the evaluation metrics for this example. We have implemented a series of [evaluation metrics](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fmetrics) we used and provided the [metric scripts](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fscripts\u002FVanillaAE\u002Fmetrics). Run:\n\n```bash\nbash scripts\u002FVanillaAE\u002Fmetrics\u002Fceleba_recon_wo_ffl.sh\nbash scripts\u002FVanillaAE\u002Fmetrics\u002Fceleba_recon_w_ffl.sh\n```\n\nYou will see the scores of different metrics. The metric logs will be saved in the respective experiment folders at `.\u002FVanillaAE\u002Fresults`.\n\n### Training\n\nWe have provided the example [training scripts](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fscripts\u002FVanillaAE\u002Ftrain). If you only have a CPU environment, please specify `--no_cuda` in the script. Run:\n\n```bash\nbash scripts\u002FVanillaAE\u002Ftrain\u002Fceleba_recon_wo_ffl.sh\nbash scripts\u002FVanillaAE\u002Ftrain\u002Fceleba_recon_w_ffl.sh \n```\n\nAfter training, inference on the newly trained models is similar to [Test and Evaluation Metrics](#test-and-evaluation-metrics). The results could be better reproduced on NVIDIA Tesla V100 GPUs with `torch\u003C=1.7.1,>=1.1.0`.\n\n## More Results\n\nHere, we show other examples of applying the proposed focal frequency loss (FFL) under diverse settings.\n\n### Image Reconstruction (VAE)\n\n![reconvae](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_061c65393874.jpg)\n\n### Image-to-Image Translation (pix2pix | SPADE)\n\n![consynI2I](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_09b73f13eb09.jpg)\n\n### Unconditional Image Synthesis (StyleGAN2)\n\n256x256 results (without truncation) and the mini-batch average spectra (adjusted to better contrast):\n\n![unsynsg2res256](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_f7eb2c63dc24.jpg)\n\n1024x1024 results (without truncation) synthesized by StyleGAN2 with FFL:\n\n![unsynsg2res1024](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_ea63a75a4578.jpg)\n\n## Citation\n\nIf you find this work useful for your research, please cite our paper:\n\n```\n@inproceedings{jiang2021focal,\n  title={Focal Frequency Loss for Image Reconstruction and Synthesis},\n  author={Jiang, Liming and Dai, Bo and Wu, Wayne and Loy, Chen Change},\n  booktitle={ICCV},\n  year={2021}\n}\n```\n\n## Acknowledgments\n\nThe code of Vanilla AE is inspired by [PyTorch DCGAN](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fexamples\u002Ftree\u002Fmaster\u002Fdcgan) and [MUNIT](https:\u002F\u002Fgithub.com\u002FNVlabs\u002FMUNIT). Part of the evaluation metric code is borrowed from [MMEditing](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fmmediting). We also apply [LPIPS](https:\u002F\u002Fgithub.com\u002Frichzhang\u002FPerceptualSimilarity) and [pytorch-fid](https:\u002F\u002Fgithub.com\u002Fmseitzer\u002Fpytorch-fid) as evaluation metrics.\n\n## License\n\nAll rights reserved. The code is released under the [MIT License](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fblob\u002Fmaster\u002FLICENSE.md).\n\nCopyright (c) 2021\n\n## Other Implementations\n\n[[**Unofficial TensorFlow Implementation**](https:\u002F\u002Fgithub.com\u002FZohebAbai\u002Ftf-focal-frequency-loss)] by [ZohebAbai](https:\u002F\u002Fgithub.com\u002FZohebAbai)","## 焦点频率损失 - 官方 PyTorch 实现\n\n![teaser](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_7884f318c1e4.jpg)\n\n本仓库提供了以下论文的官方 PyTorch 实现：\n\n**用于图像重建与合成的焦点频率损失**\u003Cbr>\n[Liming Jiang](https:\u002F\u002Fliming-jiang.com\u002F)、[Bo Dai](http:\u002F\u002Fdaibo.info\u002F)、[Wayne Wu](https:\u002F\u002Fwywu.github.io\u002F) 和 [Chen Change Loy](http:\u002F\u002Fpersonal.ie.cuhk.edu.hk\u002F~ccloy\u002F)\u003Cbr>\n发表于 ICCV 2021。\u003Cbr>\n[**项目页面**](https:\u002F\u002Fwww.mmlab-ntu.com\u002Fproject\u002Fffl\u002Findex.html) | [**论文**](https:\u002F\u002Farxiv.org\u002Fabs\u002F2012.12821) | [**海报**](https:\u002F\u002Fliming-jiang.com\u002Fprojects\u002FFFL\u002Fresources\u002Fposter.pdf) | [**幻灯片**](https:\u002F\u002Fliming-jiang.com\u002Fprojects\u002FFFL\u002Fresources\u002Fslides.pdf) | [**YouTube 演示**](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=RNTnDtKvcpc)\n> **摘要：** *得益于生成模型的发展，图像重建与合成取得了显著进展。然而，真实图像与生成图像之间仍可能存在差距，尤其是在频域方面。本研究证明，在频域中缩小这些差距可以进一步提升图像重建和合成的质量。我们提出了一种新颖的焦点频率损失函数，它能够通过降低易合成频率成分的权重，使模型自适应地关注那些难以合成的频率成分。该目标函数与现有的空间域损失互补，有效抑制了由于神经网络固有偏差而导致的重要频率信息丢失。我们展示了焦点频率损失在提升 VAE、pix2pix 和 SPADE 等流行模型的感知质量和定量性能方面的通用性和有效性，并进一步验证了其在 StyleGAN2 上的应用潜力。*\n\n## 更新\n\n- [2021年9月] 焦点频率损失的 **代码** 已 **发布**。\n\n- [2021年7月] 焦点频率损失的 **论文** 被 **ICCV 2021** 接收。\n\n## 快速入门\n\n运行 `pip install focal-frequency-loss` 进行安装。之后，您只需以下代码即可使用。\n\n```python\nfrom focal_frequency_loss import FocalFrequencyLoss as FFL\nffl = FFL(loss_weight=1.0, alpha=1.0)  # 初始化 nn.Module 类\n\nimport torch\nfake = torch.randn(4, 3, 64, 64)  # 替换为形状为 (N, C, H, W) 的预测张量\nreal = torch.randn(4, 3, 64, 64)  # 替换为形状为 (N, C, H, W) 的目标张量\n\nloss = ffl(fake, real)  # 计算焦点频率损失\n```\n\n**提示：**\n\n1. 当前支持的 PyTorch 版本：`torch>=1.1.0`。警告可忽略。请注意，论文中的实验是在 `torch\u003C=1.7.1,>=1.1.0` 下进行的。\n2. 初始化 `FocalFrequencyLoss` 类的参数：\n\t- `loss_weight (float)`：焦点频率损失的权重。默认值：1.0\n\t- `alpha (float)`：频谱权重矩阵的缩放因子，用于灵活性调整。默认值：1.0\n\t- `patch_factor (int)`：用于基于补丁的焦点频率损失时裁剪图像补丁的因子。默认值：1\n\t- `ave_spectrum (bool)`：是否使用小批量平均频谱。默认值：False\n\t- `log_matrix (bool)`：是否通过对数调整频谱权重矩阵。默认值：False\n\t- `batch_matrix (bool)`：是否使用基于批次的统计信息计算频谱权重矩阵。默认值：False\n3. 经验表明，您需要调整的主要超参数是 `loss_weight` 和 `alpha`。通常首先需要调整损失权重。随后，较大的 `alpha` 值表示模型更加专注于高频成分。我们默认使用 `alpha=1.0`。\n\n## 示例：图像重建（Vanilla AE）\n\n作为指南，我们提供了一个在 CelebA 数据集上应用所提出的焦点频率损失（FFL）进行 Vanilla AE 图像重建的示例。应用 FFL 非常简单。核心细节请参见 [此处](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fblob\u002Fmaster\u002FVanillaAE\u002Fmodels.py)。\n\n### 安装\n\n安装 [Anaconda](https:\u002F\u002Fwww.anaconda.com\u002F) 后，建议您创建一个 Python 3.8.3 的新 conda 环境：\n\n```bash\nconda create -n ffl python=3.8.3 -y\nconda activate ffl\n```\n\n克隆本仓库，安装 PyTorch 1.4.0（`torch>=1.1.0` 也可能适用）及其他依赖项：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss.git\ncd focal-frequency-loss\npip install -r VanillaAE\u002Frequirements.txt\n```\n\n### 数据集准备\n\n在此示例中，请从 CelebA 数据集的 [官方网站](https:\u002F\u002Fmmlab.ie.cuhk.edu.hk\u002Fprojects\u002FCelebA.html) 下载 [img_align_celeba.zip](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F0B7EVK8r0v71pZjFTYXZWM3FlRnM\u002Fview?usp=sharing&resourcekey=0-dYn9z10tMJOBAkviAcfdyQ)。然后，强烈建议您解压该文件，并将 `img_align_celeba` 文件夹符号链接到 `.\u002Fdatasets\u002Fceleba`，方法如下：\n\n```bash\nbash scripts\u002Fdatasets\u002Fprepare_celeba.sh [PATH_TO_IMG_ALIGN_CELEBA]\n```\n\n或者您可以直接将 `img_align_celeba` 文件夹移动到 `.\u002Fdatasets\u002Fceleba`。最终的目录结构应为：\n\n```\n├── datasets\n│    ├── celeba\n│    │    ├── img_align_celeba  \n│    │    │    ├── 000001.jpg\n│    │    │    ├── 000002.jpg\n│    │    │    ├── 000003.jpg\n│    │    │    ├── ...\n```\n\n### 测试与评估指标\n\n下载 [预训练模型](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1YIH09eoDyP2JLmiYJpju4hOkVFO7M3b_\u002Fview?usp=sharing) 并将其解压到 `.\u002FVanillaAE\u002Fexperiments`。\n\n我们提供了示例 [测试脚本](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fscripts\u002FVanillaAE\u002Ftest)。如果您只有 CPU 环境，请在脚本中指定 `--no_cuda`。运行：\n\n```bash\nbash scripts\u002FVanillaAE\u002Ftest\u002Fceleba_recon_wo_ffl.sh\nbash scripts\u002FVanillaAE\u002Ftest\u002Fceleba_recon_w_ffl.sh\n```\n\nVanilla AE 图像重建的结果将默认保存在 `.\u002FVanillaAE\u002Fresults` 中。\n\n测试完成后，您可以进一步计算本示例的评估指标。我们实现了一系列使用的 [评估指标](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fmetrics)，并提供了 [指标脚本](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fscripts\u002FVanillaAE\u002Fmetrics)。运行：\n\n```bash\nbash scripts\u002FVanillaAE\u002Fmetrics\u002Fceleba_recon_wo_ffl.sh\nbash scripts\u002FVanillaAE\u002Fmetrics\u002Fceleba_recon_w_ffl.sh\n```\n\n您将看到各项指标的得分。指标日志将保存在 `.\u002FVanillaAE\u002Fresults` 中对应的实验文件夹内。\n\n### 训练\n\n我们提供了示例 [训练脚本](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Ftree\u002Fmaster\u002Fscripts\u002FVanillaAE\u002Ftrain)。如果您只有 CPU 环境，请在脚本中指定 `--no_cuda`。运行：\n\n```bash\nbash scripts\u002FVanillaAE\u002Ftrain\u002Fceleba_recon_wo_ffl.sh\nbash scripts\u002FVanillaAE\u002Ftrain\u002Fceleba_recon_w_ffl.sh \n```\n\n训练完成后，对新训练模型的推理过程与 [测试与评估指标](#test-and-evaluation-metrics) 类似。在 NVIDIA Tesla V100 GPU 上，使用 `torch\u003C=1.7.1,>=1.1.0` 可以更好地复现结果。\n\n## 更多结果\n\n在这里，我们展示了在不同设置下应用所提出的焦点频率损失（FFL）的其他示例。\n\n### 图像重建（VAE）\n\n![reconvae](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_061c65393874.jpg)\n\n### 图像到图像转换（pix2pix | SPADE）\n\n![consynI2I](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_09b73f13eb09.jpg)\n\n### 无条件图像合成（StyleGAN2）\n\n256×256 分辨率的结果（未使用截断技巧）以及调整对比度后的迷你批次平均频谱图：\n\n![unsynsg2res256](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_f7eb2c63dc24.jpg)\n\n1024×1024 分辨率的结果（未使用截断技巧），由 StyleGAN2 结合 FFL 合成：\n\n![unsynsg2res1024](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_readme_ea63a75a4578.jpg)\n\n## 引用\n\n如果您认为本工作对您的研究有所帮助，请引用我们的论文：\n\n```\n@inproceedings{jiang2021focal,\n  title={Focal Frequency Loss for Image Reconstruction and Synthesis},\n  author={Jiang, Liming and Dai, Bo and Wu, Wayne and Loy, Chen Change},\n  booktitle={ICCV},\n  year={2021}\n}\n```\n\n## 致谢\n\nVanilla AE 的代码灵感来源于 [PyTorch DCGAN](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fexamples\u002Ftree\u002Fmaster\u002Fdcgan) 和 [MUNIT](https:\u002F\u002Fgithub.com\u002FNVlabs\u002FMUNIT)。部分评估指标代码借用了 [MMEditing](https:\u002F\u002Fgithub.com\u002Fopen-mmlab\u002Fmmediting)。此外，我们还使用了 [LPIPS](https:\u002F\u002Fgithub.com\u002Frichzhang\u002FPerceptualSimilarity) 和 [pytorch-fid](https:\u002F\u002Fgithub.com\u002Fmseitzer\u002Fpytorch-fid) 作为评估指标。\n\n## 许可证\n\n版权所有。代码以 [MIT 许可证](https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fblob\u002Fmaster\u002FLICENSE.md) 发布。\n\n版权所有 © 2021\n\n## 其他实现\n\n[[**非官方 TensorFlow 实现**](https:\u002F\u002Fgithub.com\u002FZohebAbai\u002Ftf-focal-frequency-loss)] 由 [ZohebAbai](https:\u002F\u002Fgithub.com\u002FZohebAbai) 提供","# Focal Frequency Loss 快速上手指南\n\nFocal Frequency Loss (FFL) 是一种用于图像重建和合成的损失函数，通过自适应地关注难以合成的频率分量，弥补生成图像与真实图像在频域上的差距。该工具基于 PyTorch 实现，可轻松集成到 VAE、pix2pix、StyleGAN2 等模型中。\n\n## 环境准备\n\n- **操作系统**：Linux \u002F macOS \u002F Windows\n- **Python 版本**：推荐 Python 3.8+\n- **PyTorch 版本**：`torch >= 1.1.0`（论文实验基于 `1.1.0 \u003C= torch \u003C= 1.7.1`）\n- **依赖项**：仅需安装 `focal-frequency-loss` 包，其他依赖由包自动管理\n\n> 💡 国内用户建议使用清华或阿里镜像源加速安装。\n\n## 安装步骤\n\n使用 pip 直接安装官方发布包：\n\n```bash\npip install focal-frequency-loss -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n若需从源码安装（可选）：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss.git\ncd focal-frequency-loss\npip install -e .\n```\n\n## 基本使用\n\n以下是最小可用示例，展示如何在训练循环中调用 FFL：\n\n```python\nfrom focal_frequency_loss import FocalFrequencyLoss as FFL\nffl = FFL(loss_weight=1.0, alpha=1.0)  # 初始化损失模块\n\nimport torch\nfake = torch.randn(4, 3, 64, 64)  # 模型预测输出 (N, C, H, W)\nreal = torch.randn(4, 3, 64, 64)  # 真实目标图像 (N, C, H, W)\n\nloss = ffl(fake, real)  # 计算频域焦点损失\nloss.backward()  # 反向传播\n```\n\n### 核心参数说明\n\n- `loss_weight` (float): 损失权重，默认 `1.0`，通常需根据任务调整。\n- `alpha` (float): 频谱权重矩阵的缩放因子，控制对难合成频率的关注程度，默认 `1.0`。值越大，模型越聚焦于高频细节。\n- 其他高级参数（如 `patch_factor`, `ave_spectrum` 等）可按需配置，一般场景使用默认值即可。\n\n> ✅ 建议优先调整 `loss_weight`，再微调 `alpha` 以获得最佳效果。","某医疗影像算法团队正在开发基于自编码器（AE）的肺部 CT 图像重建系统，旨在去除扫描噪声并恢复清晰的病灶细节。\n\n### 没有 focal-frequency-loss 时\n- **高频细节丢失**：模型受神经网络固有偏差影响，倾向于生成平滑图像，导致肺纹理、微小结节边缘等高频信息模糊不清。\n- **频域差距难弥合**：传统的空间域损失函数（如 MSE\u002FL1）无法有效约束频率分布，重建图像在频谱上与真实影像存在显著断层。\n- **训练重点失衡**：模型过度关注容易学习的低频背景区域，难以自适应地聚焦于那些难以合成的关键病灶特征。\n- **诊断价值受损**：生成的图像虽然整体结构正确，但缺乏临床诊断所需的精细度，可能导致微小病变漏诊。\n\n### 使用 focal-frequency-loss 后\n- **关键细节复原**：focal-frequency-loss 通过动态降低易合成频率的权重，迫使模型集中“注意力”攻克高频难点，清晰还原了肺纹理和结节边缘。\n- **频域分布对齐**：该损失函数直接在频域缩小生成图与真实图的差距，显著改善了图像的频谱一致性，消除了伪影。\n- **自适应难例挖掘**：机制允许模型自动识别并加权那些“难合成”的频率分量，避免了训练资源在简单背景上的浪费。\n- **临床可用性提升**：重建图像在感知质量和定量指标上双重提升，保留了足够的病理细节，满足了辅助诊断的严苛要求。\n\nfocal-frequency-loss 通过填补频域鸿沟，让生成模型从“大概相似”进化到“细节逼真”，解决了传统方法难以恢复高频信息的痛点。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FEndlessSora_focal-frequency-loss_7884f318.jpg","EndlessSora","Liming Jiang","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FEndlessSora_ebb55501.png","Staff Research Scientist, ByteDance \u002F TikTok, USA. Prior Ph.D., MMLab@NTU.","ByteDance \u002F TikTok","United States",null,"SoraEndless","https:\u002F\u002Fliming-jiang.com","https:\u002F\u002Fgithub.com\u002FEndlessSora",[84,88],{"name":85,"color":86,"percentage":87},"Python","#3572A5",94.3,{"name":89,"color":90,"percentage":91},"Shell","#89e051",5.7,707,62,"2026-04-04T17:02:48","MIT",1,"未说明","非必需（支持 CPU 运行，需添加 --no_cuda 参数）；论文实验及最佳复现效果推荐使用 NVIDIA Tesla V100 GPU",{"notes":100,"python":101,"dependencies":102},"1. 虽然支持 CPU 运行，但为了获得与论文一致的复现效果，建议使用 NVIDIA Tesla V100 GPU 且 PyTorch 版本在 1.1.0 到 1.7.1 之间。2. 可通过 pip 直接安装库，或通过 conda 创建包含 Python 3.8.3 的虚拟环境进行源码安装。3. 运行示例需要手动下载 CelebA 数据集和预训练模型。4. 主要超参数为 loss_weight 和 alpha。","3.8.3 (推荐), >=3.6 (隐含)",[103,65],"torch>=1.1.0",[15],[106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123],"generative-models","loss-function","frequency-domain","frequency-analysis","complementary","autoencoder","variational-autoencoder","gan","pix2pix","spade","loss","image-reconstruction","image-synthesis","stylegan2","iccv2021","generative-adversarial-network","generic","image-generation","2026-03-27T02:49:30.150509","2026-04-16T10:48:54.688802",[127,132,137,142,147,152,157],{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},35711,"是否支持 PyTorch 1.7.1 以上的版本（如 1.8.1）？","已支持。请通过 pip 升级或重新安装 `focal-frequency-loss` 包，或者直接使用该仓库中的最新代码。相关修复已提交至新 commit。","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F3",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},35712,"频率距离（freq_distance）的计算原理是什么？为什么代码中直接使用 tmp[...,0], tmp[...,1] 而不是欧几里得距离的平方运算？","可以将第 90 行 `freq_distance` 的平方根视为欧几里得距离。项目中直接应用平方欧几里得距离是为了确保梯度的平滑性。","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F9",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},35713,"是否有 TensorFlow 版本的实现？","有社区贡献的非官方 TensorFlow 实现。你可以访问该项目的 GitHub 仓库或 PyPi 页面获取。维护者已在 README 中提及此实现，且测试表明其数值结果与 PyTorch 版本完全一致。","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F8",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},35714,"如何可视化图像的频谱（spectra）？","可以使用以下 Python 代码将单通道灰度图像转换为频谱图并保存：\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# img 为从 RGB 或 BGR 转换而来的单通道灰度图像 (numpy.ndarray 或 PIL.Image)\nfreq = np.fft.fft2(img)\nfreq = np.fft.fftshift(freq)\nfreq = np.log(1 + np.abs(freq))\nplt.imsave('freq.png', freq)","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F6",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},35715,"在 GAN 训练中，FFL 损失值的合理范围是多少？如何初始化它与另一个损失函数的权重？","FFL 的值已经过归一化，通常处于合理范围内。建议初始时将两个损失函数的权重设置为相等或同一数量级，随后根据训练效果进行调整。","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F13",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},35716,"在哪里可以找到论文《Deceive D: Adaptive Pseudo Augmentation for GAN Training with Limited Data》？","该论文现已发布，可以在 arXiv 上查看：https:\u002F\u002Farxiv.org\u002Fabs\u002F2111.06849","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F5",{"id":158,"question_zh":159,"answer_zh":160,"source_url":161},35717,"训练时出现警告 'Casting complex values to real discards the imaginary part'，这会影响生成图像的质量吗？","该问题已被标记为重复问题（参考 Issue #10）。通常这是 PyTorch 内部处理复数时的提示，若损失能正常下降且图像生成正常，一般不影响最终质量，具体需结合其他复数相关问题的讨论确认。","https:\u002F\u002Fgithub.com\u002FEndlessSora\u002Ffocal-frequency-loss\u002Fissues\u002F12",[]]