[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-Stability-AI--generative-models":3,"tool-Stability-AI--generative-models":65},[4,18,32,41,49,57],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,3,"2026-04-06T03:28:53",[13,14,15,16],"开发框架","图像","Agent","视频","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":24,"last_commit_at":25,"category_tags":26,"status":17},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",85092,2,"2026-04-10T11:13:16",[14,27,16,28,15,29,30,13,31],"数据工具","插件","其他","语言模型","音频",{"id":33,"name":34,"github_repo":35,"description_zh":36,"stars":37,"difficulty_score":38,"last_commit_at":39,"category_tags":40,"status":17},5784,"funNLP","fighting41love\u002FfunNLP","funNLP 是一个专为中文自然语言处理（NLP）打造的超级资源库，被誉为\"NLP 民工的乐园”。它并非单一的软件工具，而是一个汇集了海量开源项目、数据集、预训练模型和实用代码的综合性平台。\n\n面对中文 NLP 领域资源分散、入门门槛高以及特定场景数据匮乏的痛点，funNLP 提供了“一站式”解决方案。这里不仅涵盖了分词、命名实体识别、情感分析、文本摘要等基础任务的标准工具，还独特地收录了丰富的垂直领域资源，如法律、医疗、金融行业的专用词库与数据集，甚至包含古诗词生成、歌词创作等趣味应用。其核心亮点在于极高的全面性与实用性，从基础的字典词典到前沿的 BERT、GPT-2 模型代码，再到高质量的标注数据和竞赛方案，应有尽有。\n\n无论是刚刚踏入 NLP 领域的学生、需要快速验证想法的算法工程师，还是从事人工智能研究的学者，都能在这里找到急需的“武器弹药”。对于开发者而言，它能大幅减少寻找数据和复现模型的时间；对于研究者，它提供了丰富的基准测试资源和前沿技术参考。funNLP 以开放共享的精神，极大地降低了中文自然语言处理的开发与研究成本，是中文 AI 社区不可或缺的宝藏仓库。",79857,1,"2026-04-08T20:11:31",[30,27,29],{"id":42,"name":43,"github_repo":44,"description_zh":45,"stars":46,"difficulty_score":38,"last_commit_at":47,"category_tags":48,"status":17},5773,"cs-video-courses","Developer-Y\u002Fcs-video-courses","cs-video-courses 是一个精心整理的计算机科学视频课程清单，旨在为自学者提供系统化的学习路径。它汇集了全球知名高校（如加州大学伯克利分校、新南威尔士大学等）的完整课程录像，涵盖从编程基础、数据结构与算法，到操作系统、分布式系统、数据库等核心领域，并深入延伸至人工智能、机器学习、量子计算及区块链等前沿方向。\n\n面对网络上零散且质量参差不齐的教学资源，cs-video-courses 解决了学习者难以找到成体系、高难度大学级别课程的痛点。该项目严格筛选内容，仅收录真正的大学层级课程，排除了碎片化的简短教程或商业广告，确保用户能接触到严谨的学术内容。\n\n这份清单特别适合希望夯实计算机基础的开发者、需要补充特定领域知识的研究人员，以及渴望像在校生一样系统学习计算机科学的自学者。其独特的技术亮点在于分类极其详尽，不仅包含传统的软件工程与网络安全，还细分了生成式 AI、大语言模型、计算生物学等新兴学科，并直接链接至官方视频播放列表，让用户能一站式获取高质量的教育资源，免费享受世界顶尖大学的课堂体验。",79792,"2026-04-08T22:03:59",[29,14,27,13],{"id":50,"name":51,"github_repo":52,"description_zh":53,"stars":54,"difficulty_score":10,"last_commit_at":55,"category_tags":56,"status":17},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,30,29],{"id":58,"name":59,"github_repo":60,"description_zh":61,"stars":62,"difficulty_score":10,"last_commit_at":63,"category_tags":64,"status":17},519,"PaddleOCR","PaddlePaddle\u002FPaddleOCR","PaddleOCR 是一款基于百度飞桨框架开发的高性能开源光学字符识别工具包。它的核心能力是将图片、PDF 等文档中的文字提取出来，转换成计算机可读取的结构化数据，让机器真正“看懂”图文内容。\n\n面对海量纸质或电子文档，PaddleOCR 解决了人工录入效率低、数字化成本高的问题。尤其在人工智能领域，它扮演着连接图像与大型语言模型（LLM）的桥梁角色，能将视觉信息直接转化为文本输入，助力智能问答、文档分析等应用场景落地。\n\nPaddleOCR 适合开发者、算法研究人员以及有文档自动化需求的普通用户。其技术优势十分明显：不仅支持全球 100 多种语言的识别，还能在 Windows、Linux、macOS 等多个系统上运行，并灵活适配 CPU、GPU、NPU 等各类硬件。作为一个轻量级且社区活跃的开源项目，PaddleOCR 既能满足快速集成的需求，也能支撑前沿的视觉语言研究，是处理文字识别任务的理想选择。",75334,"2026-04-10T23:08:27",[30,14,13,29],{"id":66,"github_repo":67,"name":68,"description_en":69,"description_zh":70,"ai_summary_zh":71,"readme_en":72,"readme_zh":73,"quickstart_zh":74,"use_case_zh":75,"hero_image_url":76,"owner_login":77,"owner_name":78,"owner_avatar_url":79,"owner_bio":80,"owner_company":81,"owner_location":81,"owner_email":82,"owner_twitter":81,"owner_website":83,"owner_url":84,"languages":85,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":98,"env_os":99,"env_gpu":100,"env_ram":101,"env_deps":102,"category_tags":110,"github_topics":81,"view_count":98,"oss_zip_url":81,"oss_zip_packed_at":81,"status":17,"created_at":111,"updated_at":112,"faqs":113,"releases":143},6525,"Stability-AI\u002Fgenerative-models","generative-models","Generative Models by Stability AI","Generative Models 是 Stability AI 推出的开源项目，核心亮点在于最新发布的 Stable Video 4D 2.0（SV4D 2.0）。这是一个先进的视频转 4D 扩散模型，旨在解决从单一视角视频中生成高保真、多视角动态 3D 资产的技术难题。传统方法往往难以处理物体自遮挡或背景杂乱的情况，且生成的动态细节容易模糊，而 SV4D 2.0 通过改进的架构，显著提升了运动中的画面锐度与时空一致性，无需依赖额外的多视角参考图即可稳健地合成新颖视角的视频。\n\n该项目特别适合计算机视觉研究人员、AI 开发者以及从事 3D 内容创作的设计师使用。对于研究者，它提供了探索 4D 生成前沿的完整代码与训练权重；对于开发者，其支持自动回归生成长视频及低显存优化选项，便于集成与调试；对于设计师，它能将简单的物体运动视频快速转化为可用于游戏或影视的多视角 4D 素材。技术层面，SV4D 2.0 支持一次性生成 12 帧视频对应 4 个相机视角（或 5 帧对应 8 视角），分辨率达 576x576，并能更好地泛化至真实世界场景。用户只需准备一段白底或经简单抠图处理的物体运动视频，","Generative Models 是 Stability AI 推出的开源项目，核心亮点在于最新发布的 Stable Video 4D 2.0（SV4D 2.0）。这是一个先进的视频转 4D 扩散模型，旨在解决从单一视角视频中生成高保真、多视角动态 3D 资产的技术难题。传统方法往往难以处理物体自遮挡或背景杂乱的情况，且生成的动态细节容易模糊，而 SV4D 2.0 通过改进的架构，显著提升了运动中的画面锐度与时空一致性，无需依赖额外的多视角参考图即可稳健地合成新颖视角的视频。\n\n该项目特别适合计算机视觉研究人员、AI 开发者以及从事 3D 内容创作的设计师使用。对于研究者，它提供了探索 4D 生成前沿的完整代码与训练权重；对于开发者，其支持自动回归生成长视频及低显存优化选项，便于集成与调试；对于设计师，它能将简单的物体运动视频快速转化为可用于游戏或影视的多视角 4D 素材。技术层面，SV4D 2.0 支持一次性生成 12 帧视频对应 4 个相机视角（或 5 帧对应 8 视角），分辨率达 576x576，并能更好地泛化至真实世界场景。用户只需准备一段白底或经简单抠图处理的物体运动视频，即可通过命令行轻松启动推理，体验高质量的 4D 内容生成。","# Generative Models by Stability AI\n\n![sample1](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_8717fd2a9047.jpg)\n\n## News\n\n\n**May 20, 2025**\n- We are releasing **[Stable Video 4D 2.0 (SV4D 2.0)](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d2.0)**, an enhanced video-to-4D diffusion model for high-fidelity novel-view video synthesis and 4D asset generation. For research purposes:\n    - **SV4D 2.0** was trained to generate 48 frames (12 video frames x 4 camera views) at 576x576 resolution, given a 12-frame input video of the same size, ideally consisting of white-background images of a moving object.\n    - Compared to our previous 4D model [SV4D](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d), **SV4D 2.0** can generate videos with higher fidelity, sharper details during motion, and better spatio-temporal consistency. It also generalizes much better to real-world videos. Moreover, it does not rely on refernce multi-view of the first frame generated by SV3D, making it more robust to self-occlusions.\n    - To generate longer novel-view videos, we autoregressively generate 12 frames at a time and use the previous generation as conditioning views for the remaining frames.\n    - Please check our [project page](https:\u002F\u002Fsv4d20.github.io), [arxiv paper](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2503.16396) and [video summary](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=dtqj-s50ynU) for more details.\n\n**QUICKSTART** :\n- `python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path assets\u002Fsv4d_videos\u002Fcamel.gif --output_folder outputs` (after downloading [sv4d2.safetensors](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d2.0) from HuggingFace into `checkpoints\u002F`)\n\nTo run **SV4D 2.0** on a single input video of 21 frames:\n- Download SV4D 2.0 model (`sv4d2.safetensors`) from [here](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d2.0) to `checkpoints\u002F`: `huggingface-cli download stabilityai\u002Fsv4d2.0 sv4d2.safetensors --local-dir checkpoints`\n- Run inference: `python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path \u003Cpath\u002Fto\u002Fvideo>`\n    - `input_path` : The input video `\u003Cpath\u002Fto\u002Fvideo>` can be\n      - a single video file in `gif` or `mp4` format, such as `assets\u002Fsv4d_videos\u002Fcamel.gif`, or\n      - a folder containing images of video frames in `.jpg`, `.jpeg`, or `.png` format, or\n      - a file name pattern matching images of video frames.\n    - `num_steps` : default is 50, can decrease to it to shorten sampling time.\n    - `elevations_deg` : specified elevations (reletive to input view), default is 0.0 (same as input view).\n    - **Background removal** : For input videos with plain background, (optionally) use [rembg](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg) to remove background and crop video frames by setting `--remove_bg=True`. To obtain higher quality outputs on real-world input videos with noisy background, try segmenting the foreground object using [Clipdrop](https:\u002F\u002Fclipdrop.co\u002F) or [SAM2](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything-2) before running SV4D.\n    - **Low VRAM environment** : To run on GPUs with low VRAM, try setting `--encoding_t=1` (of frames encoded at a time) and `--decoding_t=1` (of frames decoded at a time) or lower video resolution like `--img_size=512`.\n\nNotes:\n- We also train a 8-view model that generates 5 frames x 8 views at a time (same as SV4D).\n  - Download the model from huggingface: `huggingface-cli download stabilityai\u002Fsv4d2.0 sv4d2_8views.safetensors --local-dir checkpoints`\n  - Run inference: `python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --model_path checkpoints\u002Fsv4d2_8views.safetensors --input_path assets\u002Fsv4d_videos\u002Fchest.gif --output_folder outputs`\n  - The 5x8 model takes 5 frames of input at a time. But the inference scripts for both model take 21-frame video as input by default (same as SV3D and SV4D), we run the model autoregressively until we generate 21 frames.\n- Install dependencies before running:\n```\npython3.10 -m venv .generativemodels\nsource .generativemodels\u002Fbin\u002Factivate\npip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118 # check CUDA version\npip3 install -r requirements\u002Fpt2.txt\npip3 install .\npip3 install -e git+https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines.git@main#egg=sdata\n```\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_29ee16f0ca5a.gif)\n\n\n**July 24, 2024**\n- We are releasing **[Stable Video 4D (SV4D)](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d)**, a video-to-4D diffusion model for novel-view video synthesis. For research purposes:\n    - **SV4D** was trained to generate 40 frames (5 video frames x 8 camera views) at 576x576 resolution, given 5 context frames (the input video), and 8 reference views (synthesised from the first frame of the input video, using a multi-view diffusion model like SV3D) of the same size, ideally white-background images with one object.\n    - To generate longer novel-view videos (21 frames), we propose a novel sampling method using SV4D, by first sampling 5 anchor frames and then densely sampling the remaining frames while maintaining temporal consistency.\n    - To run the community-build gradio demo locally, run `python -m scripts.demo.gradio_app_sv4d`.\n    - Please check our [project page](https:\u002F\u002Fsv4d.github.io), [tech report](https:\u002F\u002Fsv4d.github.io\u002Fstatic\u002Fsv4d_technical_report.pdf) and [video summary](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=RBP8vdAWTgk) for more details.\n\n**QUICKSTART** : `python scripts\u002Fsampling\u002Fsimple_video_sample_4d.py --input_path assets\u002Fsv4d_videos\u002Ftest_video1.mp4 --output_folder outputs\u002Fsv4d` (after downloading [sv4d.safetensors](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d) and [sv3d_u.safetensors](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d) from HuggingFace into `checkpoints\u002F`)\n\nTo run **SV4D** on a single input video of 21 frames:\n- Download SV3D models (`sv3d_u.safetensors` and `sv3d_p.safetensors`) from [here](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d) and SV4D model (`sv4d.safetensors`) from [here](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d) to `checkpoints\u002F`\n- Run `python scripts\u002Fsampling\u002Fsimple_video_sample_4d.py --input_path \u003Cpath\u002Fto\u002Fvideo>`\n    - `input_path` : The input video `\u003Cpath\u002Fto\u002Fvideo>` can be\n      - a single video file in `gif` or `mp4` format, such as `assets\u002Fsv4d_videos\u002Ftest_video1.mp4`, or\n      - a folder containing images of video frames in `.jpg`, `.jpeg`, or `.png` format, or\n      - a file name pattern matching images of video frames.\n    - `num_steps` : default is 20, can increase to 50 for better quality but longer sampling time.\n    - `sv3d_version` : To specify the SV3D model to generate reference multi-views, set `--sv3d_version=sv3d_u` for SV3D_u or `--sv3d_version=sv3d_p` for SV3D_p.\n    - `elevations_deg` : To generate novel-view videos at a specified elevation (default elevation is 10) using SV3D_p (default is SV3D_u), run `python scripts\u002Fsampling\u002Fsimple_video_sample_4d.py --input_path assets\u002Fsv4d_videos\u002Ftest_video1.mp4 --sv3d_version sv3d_p --elevations_deg 30.0`\n    - **Background removal** : For input videos with plain background, (optionally) use [rembg](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg) to remove background and crop video frames by setting `--remove_bg=True`. To obtain higher quality outputs on real-world input videos with noisy background, try segmenting the foreground object using [Clipdrop](https:\u002F\u002Fclipdrop.co\u002F) or [SAM2](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything-2) before running SV4D.\n    - **Low VRAM environment** : To run on GPUs with low VRAM, try setting `--encoding_t=1` (of frames encoded at a time) and `--decoding_t=1` (of frames decoded at a time) or lower video resolution like `--img_size=512`.\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_b2160881dafe.gif)\n\n\n**March 18, 2024**\n- We are releasing **[SV3D](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d)**, an image-to-video model for novel multi-view synthesis, for research purposes:\n    - **SV3D** was trained to generate 21 frames at resolution 576x576, given 1 context frame of the same size, ideally a white-background image with one object.\n    - **SV3D_u**: This variant generates orbital videos based on single image inputs without camera conditioning..\n    - **SV3D_p**: Extending the capability of **SVD3_u**, this variant accommodates both single images and orbital views allowing for the creation of 3D video along specified camera paths.\n    - We extend the streamlit demo `scripts\u002Fdemo\u002Fvideo_sampling.py` and the standalone python script `scripts\u002Fsampling\u002Fsimple_video_sample.py` for inference of both models.\n    - Please check our [project page](https:\u002F\u002Fsv3d.github.io), [tech report](https:\u002F\u002Fsv3d.github.io\u002Fstatic\u002Fpaper.pdf) and [video summary](https:\u002F\u002Fyoutu.be\u002FZqw4-1LcfWg) for more details.\n\nTo run **SV3D_u** on a single image:\n- Download `sv3d_u.safetensors` from https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d to `checkpoints\u002Fsv3d_u.safetensors`\n- Run `python scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_u`\n\nTo run **SV3D_p** on a single image:\n- Download `sv3d_p.safetensors` from https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d to `checkpoints\u002Fsv3d_p.safetensors`\n1. Generate static orbit at a specified elevation eg. 10.0 : `python scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_p --elevations_deg 10.0`\n2. Generate dynamic orbit at a specified elevations and azimuths: specify sequences of 21 elevations (in degrees) to `elevations_deg` ([-90, 90]), and 21 azimuths (in degrees) to `azimuths_deg` [0, 360] in sorted order from 0 to 360. For example: `python scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_p --elevations_deg [\u003Clist of 21 elevations in degrees>] --azimuths_deg [\u003Clist of 21 azimuths in degrees>]`\n\nTo run SVD or SV3D on a streamlit server:\n`streamlit run scripts\u002Fdemo\u002Fvideo_sampling.py`\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_57a7f2eb428d.gif)\n\n\n**November 28, 2023**\n- We are releasing SDXL-Turbo, a lightning fast text-to image model.\n  Alongside the model, we release a [technical report](https:\u002F\u002Fstability.ai\u002Fresearch\u002Fadversarial-diffusion-distillation)\n    - Usage:\n        - Follow the installation instructions or update the existing environment with `pip install streamlit-keyup`.\n        - Download the [weights](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsdxl-turbo) and place them in the `checkpoints\u002F` directory.\n        - Run `streamlit run scripts\u002Fdemo\u002Fturbo.py`.\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_07fe9e431dd8.png)\n\n\n**November 21, 2023**\n- We are releasing Stable Video Diffusion, an image-to-video model, for research purposes:\n    - [SVD](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-video-diffusion-img2vid): This model was trained to generate 14\n      frames at resolution 576x1024 given a context frame of the same size.\n      We use the standard image encoder from SD 2.1, but replace the decoder with a temporally-aware `deflickering decoder`.\n    - [SVD-XT](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-video-diffusion-img2vid-xt): Same architecture as `SVD` but finetuned\n      for 25 frame generation.\n    - You can run the community-build gradio demo locally by running `python -m scripts.demo.gradio_app`.\n    - We provide a streamlit demo `scripts\u002Fdemo\u002Fvideo_sampling.py` and a standalone python script `scripts\u002Fsampling\u002Fsimple_video_sample.py` for inference of both models.\n    - Alongside the model, we release a [technical report](https:\u002F\u002Fstability.ai\u002Fresearch\u002Fstable-video-diffusion-scaling-latent-video-diffusion-models-to-large-datasets).\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_1cc5f222c2d9.gif)\n\n**July 26, 2023**\n\n- We are releasing two new open models with a\n  permissive [`CreativeML Open RAIL++-M` license](model_licenses\u002FLICENSE-SDXL1.0) (see [Inference](#inference) for file\n  hashes):\n    - [SDXL-base-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0): An improved version\n      over `SDXL-base-0.9`.\n    - [SDXL-refiner-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0): An improved version\n      over `SDXL-refiner-0.9`.\n\n![sample2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_6184d7fc6659.png)\n\n**July 4, 2023**\n\n- A technical report on SDXL is now available [here](https:\u002F\u002Farxiv.org\u002Fabs\u002F2307.01952).\n\n**June 22, 2023**\n\n- We are releasing two new diffusion models for research purposes:\n    - `SDXL-base-0.9`: The base model was trained on a variety of aspect ratios on images with resolution 1024^2. The\n      base model uses [OpenCLIP-ViT\u002FG](https:\u002F\u002Fgithub.com\u002Fmlfoundations\u002Fopen_clip)\n      and [CLIP-ViT\u002FL](https:\u002F\u002Fgithub.com\u002Fopenai\u002FCLIP\u002Ftree\u002Fmain) for text encoding whereas the refiner model only uses\n      the OpenCLIP model.\n    - `SDXL-refiner-0.9`: The refiner has been trained to denoise small noise levels of high quality data and as such is\n      not expected to work as a text-to-image model; instead, it should only be used as an image-to-image model.\n\nIf you would like to access these models for your research, please apply using one of the following links:\n[SDXL-0.9-Base model](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-0.9),\nand [SDXL-0.9-Refiner](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-0.9).\nThis means that you can apply for any of the two links - and if you are granted - you can access both.\nPlease log in to your Hugging Face Account with your organization email to request access.\n**We plan to do a full release soon (July).**\n\n## The codebase\n\n### General Philosophy\n\nModularity is king. This repo implements a config-driven approach where we build and combine submodules by\ncalling `instantiate_from_config()` on objects defined in yaml configs. See `configs\u002F` for many examples.\n\n### Changelog from the old `ldm` codebase\n\nFor training, we use [PyTorch Lightning](https:\u002F\u002Flightning.ai\u002Fdocs\u002Fpytorch\u002Fstable\u002F), but it should be easy to use other\ntraining wrappers around the base modules. The core diffusion model class (formerly `LatentDiffusion`,\nnow `DiffusionEngine`) has been cleaned up:\n\n- No more extensive subclassing! We now handle all types of conditioning inputs (vectors, sequences and spatial\n  conditionings, and all combinations thereof) in a single class: `GeneralConditioner`,\n  see `sgm\u002Fmodules\u002Fencoders\u002Fmodules.py`.\n- We separate guiders (such as classifier-free guidance, see `sgm\u002Fmodules\u002Fdiffusionmodules\u002Fguiders.py`) from the\n  samplers (`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fsampling.py`), and the samplers are independent of the model.\n- We adopt the [\"denoiser framework\"](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.00364) for both training and inference (most notable\n  change is probably now the option to train continuous time models):\n    * Discrete times models (denoisers) are simply a special case of continuous time models (denoisers);\n      see `sgm\u002Fmodules\u002Fdiffusionmodules\u002Fdenoiser.py`.\n    * The following features are now independent: weighting of the diffusion loss\n      function (`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fdenoiser_weighting.py`), preconditioning of the\n      network (`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fdenoiser_scaling.py`), and sampling of noise levels during\n      training (`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fsigma_sampling.py`).\n- Autoencoding models have also been cleaned up.\n\n## Installation:\n\n\u003Ca name=\"installation\">\u003C\u002Fa>\n\n#### 1. Clone the repo\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models.git\ncd generative-models\n```\n\n#### 2. Setting up the virtualenv\n\nThis is assuming you have navigated to the `generative-models` root after cloning it.\n\n**NOTE:** This is tested under `python3.10`. For other python versions, you might encounter version conflicts.\n\n**PyTorch 2.0**\n\n```shell\n# install required packages from pypi\npython3 -m venv .pt2\nsource .pt2\u002Fbin\u002Factivate\npip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\npip3 install -r requirements\u002Fpt2.txt\n```\n\n#### 3. Install `sgm`\n\n```shell\npip3 install .\n```\n\n#### 4. Install `sdata` for training\n\n```shell\npip3 install -e git+https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines.git@main#egg=sdata\n```\n\n## Packaging\n\nThis repository uses PEP 517 compliant packaging using [Hatch](https:\u002F\u002Fhatch.pypa.io\u002Flatest\u002F).\n\nTo build a distributable wheel, install `hatch` and run `hatch build`\n(specifying `-t wheel` will skip building a sdist, which is not necessary).\n\n```\npip install hatch\nhatch build -t wheel\n```\n\nYou will find the built package in `dist\u002F`. You can install the wheel with `pip install dist\u002F*.whl`.\n\nNote that the package does **not** currently specify dependencies; you will need to install the required packages,\ndepending on your use case and PyTorch version, manually.\n\n## Inference\n\nWe provide a [streamlit](https:\u002F\u002Fstreamlit.io\u002F) demo for text-to-image and image-to-image sampling\nin `scripts\u002Fdemo\u002Fsampling.py`.\nWe provide file hashes for the complete file as well as for only the saved tensors in the file (\nsee [Model Spec](https:\u002F\u002Fgithub.com\u002FStability-AI\u002FModelSpec) for a script to evaluate that).\nThe following models are currently supported:\n\n- [SDXL-base-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0)\n  ```\n  File Hash (sha256): 31e35c80fc4829d14f90153f4c74cd59c90b779f6afe05a74cd6120b893f7e5b\n  Tensordata Hash (sha256): 0xd7a9105a900fd52748f20725fe52fe52b507fd36bee4fc107b1550a26e6ee1d7\n  ```\n- [SDXL-refiner-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0)\n  ```\n  File Hash (sha256): 7440042bbdc8a24813002c09b6b69b64dc90fded4472613437b7f55f9b7d9c5f\n  Tensordata Hash (sha256): 0x1a77d21bebc4b4de78c474a90cb74dc0d2217caf4061971dbfa75ad406b75d81\n  ```\n- [SDXL-base-0.9](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-0.9)\n- [SDXL-refiner-0.9](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-0.9)\n\n**Weights for SDXL**:\n\n**SDXL-1.0:**\nThe weights of SDXL-1.0 are available (subject to\na [`CreativeML Open RAIL++-M` license](model_licenses\u002FLICENSE-SDXL1.0)) here:\n\n- base model: https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0\u002F\n- refiner model: https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0\u002F\n\n**SDXL-0.9:**\nThe weights of SDXL-0.9 are available and subject to a [research license](model_licenses\u002FLICENSE-SDXL0.9).\nIf you would like to access these models for your research, please apply using one of the following links:\n[SDXL-base-0.9 model](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-0.9),\nand [SDXL-refiner-0.9](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-0.9).\nThis means that you can apply for any of the two links - and if you are granted - you can access both.\nPlease log in to your Hugging Face Account with your organization email to request access.\n\nAfter obtaining the weights, place them into `checkpoints\u002F`.\nNext, start the demo using\n\n```\nstreamlit run scripts\u002Fdemo\u002Fsampling.py --server.port \u003Cyour_port>\n```\n\n### Invisible Watermark Detection\n\nImages generated with our code use the\n[invisible-watermark](https:\u002F\u002Fgithub.com\u002FShieldMnt\u002Finvisible-watermark\u002F)\nlibrary to embed an invisible watermark into the model output. We also provide\na script to easily detect that watermark. Please note that this watermark is\nnot the same as in previous Stable Diffusion 1.x\u002F2.x versions.\n\nTo run the script you need to either have a working installation as above or\ntry an _experimental_ import using only a minimal amount of packages:\n\n```bash\npython -m venv .detect\nsource .detect\u002Fbin\u002Factivate\n\npip install \"numpy>=1.17\" \"PyWavelets>=1.1.1\" \"opencv-python>=4.1.0.25\"\npip install --no-deps invisible-watermark\n```\n\nTo run the script you need to have a working installation as above. The script\nis then useable in the following ways (don't forget to activate your\nvirtual environment beforehand, e.g. `source .pt1\u002Fbin\u002Factivate`):\n\n```bash\n# test a single file\npython scripts\u002Fdemo\u002Fdetect.py \u003Cyour filename here>\n# test multiple files at once\npython scripts\u002Fdemo\u002Fdetect.py \u003Cfilename 1> \u003Cfilename 2> ... \u003Cfilename n>\n# test all files in a specific folder\npython scripts\u002Fdemo\u002Fdetect.py \u003Cyour folder name here>\u002F*\n```\n\n## Training:\n\nWe are providing example training configs in `configs\u002Fexample_training`. To launch a training, run\n\n```\npython main.py --base configs\u002F\u003Cconfig1.yaml> configs\u002F\u003Cconfig2.yaml>\n```\n\nwhere configs are merged from left to right (later configs overwrite the same values).\nThis can be used to combine model, training and data configs. However, all of them can also be\ndefined in a single config. For example, to run a class-conditional pixel-based diffusion model training on MNIST,\nrun\n\n```bash\npython main.py --base configs\u002Fexample_training\u002Ftoy\u002Fmnist_cond.yaml\n```\n\n**NOTE 1:** Using the non-toy-dataset\nconfigs `configs\u002Fexample_training\u002Fimagenet-f8_cond.yaml`, `configs\u002Fexample_training\u002Ftxt2img-clipl.yaml`\nand `configs\u002Fexample_training\u002Ftxt2img-clipl-legacy-ucg-training.yaml` for training will require edits depending on the\nused dataset (which is expected to stored in tar-file in\nthe [webdataset-format](https:\u002F\u002Fgithub.com\u002Fwebdataset\u002Fwebdataset)). To find the parts which have to be adapted, search\nfor comments containing `USER:` in the respective config.\n\n**NOTE 2:** This repository supports both `pytorch1.13` and `pytorch2`for training generative models. However for\nautoencoder training as e.g. in `configs\u002Fexample_training\u002Fautoencoder\u002Fkl-f4\u002Fimagenet-attnfree-logvar.yaml`,\nonly `pytorch1.13` is supported.\n\n**NOTE 3:** Training latent generative models (as e.g. in `configs\u002Fexample_training\u002Fimagenet-f8_cond.yaml`) requires\nretrieving the checkpoint from [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsdxl-vae\u002Ftree\u002Fmain) and replacing\nthe `CKPT_PATH` placeholder in [this line](configs\u002Fexample_training\u002Fimagenet-f8_cond.yaml#81). The same is to be done\nfor the provided text-to-image configs.\n\n### Building New Diffusion Models\n\n#### Conditioner\n\nThe `GeneralConditioner` is configured through the `conditioner_config`. Its only attribute is `emb_models`, a list of\ndifferent embedders (all inherited from `AbstractEmbModel`) that are used to condition the generative model.\nAll embedders should define whether or not they are trainable (`is_trainable`, default `False`), a classifier-free\nguidance dropout rate is used (`ucg_rate`, default `0`), and an input key (`input_key`), for example, `txt` for\ntext-conditioning or `cls` for class-conditioning.\nWhen computing conditionings, the embedder will get `batch[input_key]` as input.\nWe currently support two to four dimensional conditionings and conditionings of different embedders are concatenated\nappropriately.\nNote that the order of the embedders in the `conditioner_config` is important.\n\n#### Network\n\nThe neural network is set through the `network_config`. This used to be called `unet_config`, which is not general\nenough as we plan to experiment with transformer-based diffusion backbones.\n\n#### Loss\n\nThe loss is configured through `loss_config`. For standard diffusion model training, you will have to\nset `sigma_sampler_config`.\n\n#### Sampler config\n\nAs discussed above, the sampler is independent of the model. In the `sampler_config`, we set the type of numerical\nsolver, number of steps, type of discretization, as well as, for example, guidance wrappers for classifier-free\nguidance.\n\n### Dataset Handling\n\nFor large scale training we recommend using the data pipelines from\nour [data pipelines](https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines) project. The project is contained in the requirement\nand automatically included when following the steps from the [Installation section](#installation).\nSmall map-style datasets should be defined here in the repository (e.g., MNIST, CIFAR-10, ...), and return a dict of\ndata keys\u002Fvalues,\ne.g.,\n\n```python\nexample = {\"jpg\": x,  # this is a tensor -1...1 chw\n           \"txt\": \"a beautiful image\"}\n```\n\nwhere we expect images in -1...1, channel-first format.\n","# 稳定人工智能的生成模型\n\n![sample1](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_8717fd2a9047.jpg)\n\n## 新闻\n\n\n**2025年5月20日**\n- 我们发布了 **[Stable Video 4D 2.0 (SV4D 2.0)](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d2.0)**，这是一款增强型视频转4D扩散模型，用于高保真新视角视频合成和4D资产生成。研究用途如下：\n    - **SV4D 2.0** 经过训练，可在给定12帧输入视频（分辨率同样为576x576）的情况下，生成48帧（12个视频帧 × 4个相机视角），理想情况下这些输入视频应由白色背景下的运动物体图像组成。\n    - 与我们之前的4D模型 [SV4D](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d) 相比，**SV4D 2.0** 能够生成更高保真的视频，在运动过程中细节更加清晰，并且具有更好的时空一致性。此外，它对真实世界视频的泛化能力也显著提升。更重要的是，该模型不再依赖于SV3D生成的第一帧参考多视角信息，因此在自我遮挡情况下表现更为稳健。\n    - 为了生成更长的新视角视频，我们采用自回归方式每次生成12帧，并将前一次生成的帧作为后续帧的条件视图。\n    - 更多详情请查看我们的 [项目页面](https:\u002F\u002Fsv4d20.github.io)、[arXiv论文](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2503.16396)以及 [视频摘要](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=dtqj-s50ynU)。\n\n**快速入门**：\n- `python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path assets\u002Fsv4d_videos\u002Fcamel.gif --output_folder outputs`（需先从HuggingFace下载 [sv4d2.safetensors](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d2.0) 并放置于 `checkpoints\u002F` 目录下）\n\n要在单个21帧输入视频上运行 **SV4D 2.0**：\n- 从 [这里](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d2.0) 下载 SV4D 2.0 模型文件 (`sv4d2.safetensors`) 并存入 `checkpoints\u002F`：`huggingface-cli download stabilityai\u002Fsv4d2.0 sv4d2.safetensors --local-dir checkpoints`\n- 运行推理：`python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path \u003Cpath\u002Fto\u002Fvideo>`\n    - `input_path`：输入视频 `\u003Cpath\u002Fto\u002Fvideo>` 可以是\n      - 单个 `gif` 或 `mp4` 格式的视频文件，例如 `assets\u002Fsv4d_videos\u002Fcamel.gif`；\n      - 包含视频帧图像的文件夹，格式为 `.jpg`、`.jpeg` 或 `.png`；\n      - 或者匹配视频帧图像的文件名模式。\n    - `num_steps`：默认值为50，可适当减少以缩短采样时间。\n    - `elevations_deg`：指定相对于输入视角的仰角，默认为0.0（即与输入视角相同）。\n    - **背景去除**：对于背景较为简单的输入视频，可选择使用 [rembg](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg) 工具去除背景并裁剪视频帧，只需设置 `--remove_bg=True`。若要获得高质量输出，针对背景较杂乱的真实世界视频，建议在运行SV4D之前先使用 [Clipdrop](https:\u002F\u002Fclipdrop.co\u002F) 或 [SAM2](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything-2) 对前景对象进行分割。\n    - **低显存环境**：若GPU显存较低，可尝试将 `--encoding_t=1`（每次编码的帧数）和 `--decoding_t=1`（每次解码的帧数）设置为1，或将视频分辨率降低至 `--img_size=512`。\n\n注：\n- 我们还训练了一个8视角模型，该模型每次可生成5帧 × 8个视角（与SV4D相同）。\n  - 从HuggingFace下载该模型：`huggingface-cli download stabilityai\u002Fsv4d2.0 sv4d2_8views.safetensors --local-dir checkpoints`\n  - 运行推理：`python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --model_path checkpoints\u002Fsv4d2_8views.safetensors --input_path assets\u002Fsv4d_videos\u002Fchest.gif --output_folder outputs`\n  - 该5×8模型每次处理5帧输入。不过，两种模型的推理脚本默认都以21帧视频作为输入（与SV3D和SV4D一致），我们会通过自回归方式持续运行模型，直到生成21帧为止。\n- 在运行前，请先安装依赖项：\n```\npython3.10 -m venv .generativemodels\nsource .generativemodels\u002Fbin\u002Factivate\npip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118 # 检查CUDA版本\npip3 install -r requirements\u002Fpt2.txt\npip3 install .\npip3 install -e git+https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines.git@main#egg=sdata\n```\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_29ee16f0ca5a.gif)\n\n\n**2024年7月24日**\n- 我们发布了 **[Stable Video 4D (SV4D)](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d)**，这是一套用于新视角视频合成的视频转4D扩散模型。研究用途如下：\n    - **SV4D** 经过训练，可在给定5帧上下文视频（即输入视频）以及8个参考视角（通过类似SV3D的多视角扩散模型从输入视频的第一帧中合成，分辨率同样为576x576）的情况下，生成40帧（5个视频帧 × 8个相机视角）。理想情况下，这些参考视角应为白色背景下的单物体图像。\n    - 为了生成更长的新视角视频（21帧），我们提出了一种基于SV4D的创新采样方法：先采样5个锚定帧，再密集采样剩余帧，同时保持时间一致性。\n    - 如需本地运行社区构建的Gradio演示程序，可执行 `python -m scripts.demo.gradio_app_sv4d`。\n    - 更多详情请参阅我们的 [项目页面](https:\u002F\u002Fsv4d.github.io)、[技术报告](https:\u002F\u002Fsv4d.github.io\u002Fstatic\u002Fsv4d_technical_report.pdf) 和 [视频摘要](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=RBP8vdAWTgk)。\n\n**快速入门**：`python scripts\u002Fsampling\u002Fsimple_video_sample_4d.py --input_path assets\u002Fsv4d_videos\u002Ftest_video1.mp4 --output_folder outputs\u002Fsv4d`（需先从HuggingFace下载 [sv4d.safetensors](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d) 和 [sv3d_u.safetensors](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d) 并放置于 `checkpoints\u002F` 目录下）\n\n要在单个包含 21 帧的输入视频上运行 **SV4D**：\n- 从 [这里](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d) 下载 SV3D 模型文件（`sv3d_u.safetensors` 和 `sv3d_p.safetensors`），并从 [这里](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv4d) 下载 SV4D 模型文件（`sv4d.safetensors`），存入 `checkpoints\u002F` 目录。\n- 运行 `python scripts\u002Fsampling\u002Fsimple_video_sample_4d.py --input_path \u003Cpath\u002Fto\u002Fvideo>`\n  - `input_path`：输入视频 `\u003Cpath\u002Fto\u002Fvideo>` 可以是\n    - 单个 `gif` 或 `mp4` 格式的视频文件，例如 `assets\u002Fsv4d_videos\u002Ftest_video1.mp4`，或\n    - 包含视频帧图像的文件夹，图像格式为 `.jpg`、`.jpeg` 或 `.png`，或\n    - 匹配视频帧图像的文件名模式。\n  - `num_steps`：默认值为 20，可增加至 50 以获得更高画质，但采样时间会更长。\n  - `sv3d_version`：要指定用于生成参考多视角的 SV3D 模型，请设置 `--sv3d_version=sv3d_u` 使用 SV3D_u，或 `--sv3d_version=sv3d_p` 使用 SV3D_p。\n  - `elevations_deg`：要使用 SV3D_p（默认为 SV3D_u）生成特定仰角的新视角视频，请运行 `python scripts\u002Fsampling\u002Fsimple_video_sample_4d.py --input_path assets\u002Fsv4d_videos\u002Ftest_video1.mp4 --sv3d_version sv3d_p --elevations_deg 30.0`。\n  - **背景去除**：对于背景简单的输入视频，（可选）使用 [rembg](https:\u002F\u002Fgithub.com\u002Fdanielgatis\u002Frembg) 去除背景，并通过设置 `--remove_bg=True` 裁剪视频帧。若要对带有杂乱背景的真实世界输入视频获得更高质量的输出，可在运行 SV4D 之前先使用 [Clipdrop](https:\u002F\u002Fclipdrop.co\u002F) 或 [SAM2](https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fsegment-anything-2) 对前景对象进行分割。\n  - **低显存环境**：若在显存较低的 GPU 上运行，可尝试将 `--encoding_t=1`（每次编码的帧数）和 `--decoding_t=1`（每次解码的帧数）设置为 1，或将视频分辨率调低，例如设置为 `--img_size=512`。\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_b2160881dafe.gif)\n\n\n**2024年3月18日**\n- 我们发布了用于新视角合成的研究级图像转视频模型 **[SV3D](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d)**：\n  - **SV3D** 经过训练，可在给定一张相同尺寸的上下文帧的情况下生成 21 帧，分辨率为 576x576，理想情况下该上下文帧应为白色背景且仅包含一个物体。\n  - **SV3D_u**：此变体基于单张图像输入生成环绕式视频，无需相机条件控制。\n  - **SV3D_p**：作为 **SVD3_u** 的扩展，此变体既支持单张图像输入，也支持环绕视图输入，从而能够沿着指定的摄像机路径创建 3D 视频。\n  - 我们扩展了 Streamlit 演示程序 `scripts\u002Fdemo\u002Fvideo_sampling.py` 和独立 Python 脚本 `scripts\u002Fsampling\u002Fsimple_video_sample.py` 以用于两种模型的推理。\n  - 更多详情请参阅我们的 [项目页面](https:\u002F\u002Fsv3d.github.io)、[技术报告](https:\u002F\u002Fsv3d.github.io\u002Fstatic\u002Fpaper.pdf) 和 [视频摘要](https:\u002F\u002Fyoutu.be\u002FZqw4-1LcfWg)。\n\n要在单张图片上运行 **SV3D_u**：\n- 从 https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d 下载 `sv3d_u.safetensors`，存入 `checkpoints\u002Fsv3d_u.safetensors`。\n- 运行 `python scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_u`。\n\n要在单张图片上运行 **SV3D_p**：\n- 从 https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsv3d 下载 `sv3d_p.safetensors`，存入 `checkpoints\u002Fsv3d_p.safetensors`。\n1. 生成指定仰角的静态环绕视频，例如 10.0 度：`python scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_p --elevations_deg 10.0`。\n2. 生成指定仰角和方位角的动态环绕视频：将 21 个仰角（以度为单位）按顺序填入 `elevations_deg`（范围为 [-90, 90]），并将 21 个方位角（以度为单位）按顺序填入 `azimuths_deg`（范围为 [0, 360]）。例如：`python scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_p --elevations_deg [\u003C21个仰角列表>] --azimuths_deg [\u003C21个方位角列表>]`。\n\n要在 Streamlit 服务器上运行 SVD 或 SV3D：\n`streamlit run scripts\u002Fdemo\u002Fvideo_sampling.py`\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_57a7f2eb428d.gif)\n\n\n**2023年11月28日**\n- 我们发布了超快速文本转图像模型 SDXL-Turbo。\n  伴随该模型发布了一份 [技术报告](https:\u002F\u002Fstability.ai\u002Fresearch\u002Fadversarial-diffusion-distillation)。\n  - 使用方法：\n    - 按照安装说明操作，或使用 `pip install streamlit-keyup` 更新现有环境。\n    - 下载 [权重](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsdxl-turbo)，并将其放置在 `checkpoints\u002F` 目录中。\n    - 运行 `streamlit run scripts\u002Fdemo\u002Fturbo.py`。\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_07fe9e431dd8.png)\n\n\n**2023年11月21日**\n- 我们发布了用于研究目的的图像转视频模型 Stable Video Diffusion：\n  - [SVD](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-video-diffusion-img2vid)：该模型经过训练，可在给定一张相同尺寸的上下文帧的情况下生成 14 帧，分辨率为 576x1024。\n    我们使用 SD 2.1 的标准图像编码器，但用具备时间感知能力的“防闪烁解码器”替换了原有的解码器。\n  - [SVD-XT](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-video-diffusion-img2vid-xt)：与 `SVD` 具有相同的架构，但经过微调后可生成 25 帧。\n  - 您可以通过运行 `python -m scripts.demo.gradio_app` 在本地运行社区构建的 Gradio 演示。\n  - 我们提供了 Streamlit 演示 `scripts\u002Fdemo\u002Fvideo_sampling.py` 和独立 Python 脚本 `scripts\u002Fsampling\u002Fsimple_video_sample.py` 用于两种模型的推理。\n  - 伴随该模型发布了一篇 [技术报告](https:\u002F\u002Fstability.ai\u002Fresearch\u002Fstable-video-diffusion-scaling-latent-video-diffusion-models-to-large-datasets)。\n\n  ![tile](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_1cc5f222c2d9.gif)\n\n**2023年7月26日**\n\n- 我们发布了两款新的开放模型，采用宽松的 [`CreativeML Open RAIL++-M` 许可证](model_licenses\u002FLICENSE-SDXL1.0)（有关文件哈希值，请参阅 [推理](#inference) 部分）：\n  - [SDXL-base-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0)：这是对 `SDXL-base-0.9` 的改进版本。\n  - [SDXL-refiner-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0)：这是对 `SDXL-refiner-0.9` 的改进版本。\n\n![sample2](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_readme_6184d7fc6659.png)\n\n**2023年7月4日**\n\n- 关于 SDXL 的技术报告现已发布 [此处](https:\u002F\u002Farxiv.org\u002Fabs\u002F2307.01952)。\n\n**2023年6月22日**\n\n- 我们发布了两款用于研究的新扩散模型：\n    - `SDXL-base-0.9`：基础模型在分辨率为1024^2、多种宽高比的图像上进行训练。该基础模型使用[OpenCLIP-ViT\u002FG](https:\u002F\u002Fgithub.com\u002Fmlfoundations\u002Fopen_clip)\n      和[CLIP-ViT\u002FL](https:\u002F\u002Fgithub.com\u002Fopenai\u002FCLIP\u002Ftree\u002Fmain)进行文本编码，而精炼模型仅使用OpenCLIP模型。\n    - `SDXL-refiner-0.9`：精炼模型经过训练，能够去除高质量数据中的少量噪声，因此不建议将其用作文生图模型；相反，它应仅作为图生图模型使用。\n\n如果您希望为研究目的访问这些模型，请通过以下链接之一申请：\n[SDXL-0.9-基础模型](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-0.9),\n以及 [SDXL-0.9-精炼模型](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-0.9)。\n这意味着您可以申请其中任一链接，一旦获批，即可同时访问两个模型。\n请使用您的组织邮箱登录Hugging Face账户以请求访问权限。\n**我们计划于近期（7月）进行全面发布。**\n\n\n\n## 代码库\n\n### 总体理念\n\n模块化至上。本仓库采用配置驱动的方法，通过调用yaml配置文件中定义的对象上的`instantiate_from_config()`来构建和组合子模块。详细示例请参见`configs\u002F`目录。\n\n### 与旧版`ldm`代码库的变更日志\n\n在训练方面，我们使用[PyTorch Lightning](https:\u002F\u002Flightning.ai\u002Fdocs\u002Fpytorch\u002Fstable\u002F)，但也可以轻松地将其他训练框架应用于基础模块。核心扩散模型类（原名为`LatentDiffusion`，现为`DiffusionEngine`）已得到优化：\n\n- 不再进行复杂的子类化！我们现在在一个类中处理所有类型的条件输入（向量、序列和空间条件，以及它们的各种组合）：`GeneralConditioner`，\n  见`sgm\u002Fmodules\u002Fencoders\u002Fmodules.py`。\n- 我们将引导器（如无分类器指导，见`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fguiders.py`）与采样器（`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fsampling.py`）分离，且采样器与模型无关。\n- 我们采用了“去噪器框架”（[arXiv:2206.00364](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.00364)），用于训练和推理（最显著的变化可能是现在可以选择训练连续时间模型）：\n    * 离散时间模型（去噪器）只是连续时间模型（去噪器）的一种特例；\n      见`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fdenoiser.py`。\n    * 以下功能现已独立：扩散损失函数的加权（`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fdenoiser_weighting.py`）、网络的预处理（`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fdenoiser_scaling.py`）以及训练过程中噪声水平的采样（`sgm\u002Fmodules\u002Fdiffusionmodules\u002Fsigma_sampling.py`）。\n- 自编码模型也得到了清理。\n\n## 安装：\n\n\u003Ca name=\"installation\">\u003C\u002Fa>\n\n#### 1. 克隆仓库\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models.git\ncd generative-models\n```\n\n#### 2. 设置虚拟环境\n\n假设您已在克隆后导航到`generative-models`根目录。\n\n**注意：** 本环境已在`python3.10`下测试通过。对于其他Python版本，可能会遇到版本冲突。\n\n**PyTorch 2.0**\n\n```shell\n# 从pypi安装所需包\npython3 -m venv .pt2\nsource .pt2\u002Fbin\u002Factivate\npip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\npip3 install -r requirements\u002Fpt2.txt\n```\n\n#### 3. 安装`sgm`\n\n```shell\npip3 install .\n```\n\n#### 4. 安装`sdata`以用于训练\n\n```shell\npip3 install -e git+https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines.git@main#egg=sdata\n```\n\n## 打包\n\n本仓库使用符合PEP 517标准的打包方式，并借助[Hatch](https:\u002F\u002Fhatch.pypa.io\u002Flatest\u002F)工具。\n\n要构建可分发的wheel包，需先安装`hatch`，然后运行`hatch build`\n（指定`-t wheel`会跳过sdist的构建，这并非必需）。\n\n```\npip install hatch\nhatch build -t wheel\n```\n\n构建好的包将位于`dist\u002F`目录中。您可以使用`pip install dist\u002F*.whl`来安装该wheel包。\n\n请注意，当前该包并未指定依赖项；您需要根据具体用途及PyTorch版本，手动安装所需的软件包。\n\n## 推理\n\n我们在`scripts\u002Fdemo\u002Fsampling.py`中提供了一个基于[Streamlit](https:\u002F\u002Fstreamlit.io\u002F)的文生图和图生图采样演示。\n我们提供了完整文件以及文件中保存张量部分的哈希值（有关评估脚本，请参阅[Model Spec](https:\u002F\u002Fgithub.com\u002FStability-AI\u002FModelSpec)）。\n目前支持以下模型：\n\n- [SDXL-base-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0)\n  ```\n  文件哈希（sha256）：31e35c80fc4829d14f90153f4c74cd59c90b779f6afe05a74cd6120b893f7e5b\n  张量数据哈希（sha256）：0xd7a9105a900fd52748f20725fe52fe52b507fd36bee4fc107b1550a26e6ee1d7\n  ```\n- [SDXL-refiner-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0)\n  ```\n  文件哈希（sha256）：7440042bbdc8a24813002c09b6b69b64dc90fded4472613437b7f55f9b7d9c5f\n  张量数据哈希（sha256）：0x1a77d21bebc4b4de78c474a90cb74dc0d2217caf4061971dbfa75ad406b75d81\n  ```\n- [SDXL-base-0.9](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-0.9)\n- [SDXL-refiner-0.9](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-0.9)\n\n**SDXL权重：**\n\n**SDXL-1.0：**\nSDXL-1.0的权重可通过[CreativeML Open RAIL++-M许可协议](model_licenses\u002FLICENSE-SDXL1.0)获取，具体如下：\n\n- 基础模型：https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0\u002F\n- 精炼模型：https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0\u002F\n\n**SDXL-0.9：**\nSDXL-0.9的权重可通过[研究许可协议](model_licenses\u002FLICENSE-SDXL0.9)获取。如果您希望为研究目的访问这些模型，请通过以下链接之一申请：\n[SDXL-base-0.9模型](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-0.9),\n以及 [SDXL-refiner-0.9](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-0.9)。\n这意味着您可以申请任一链接，一旦获批，即可同时访问两个模型。请使用您的组织邮箱登录Hugging Face账户以请求访问权限。\n\n获取权重后，请将其放置于`checkpoints\u002F`目录中。随后，启动演示程序：\n\n```\nstreamlit run scripts\u002Fdemo\u002Fsampling.py --server.port \u003Cyour_port>\n```\n\n### 无形水印检测\n\n使用我们的代码生成的图像会利用\n[invisible-watermark](https:\u002F\u002Fgithub.com\u002FShieldMnt\u002Finvisible-watermark\u002F)\n库，在模型输出中嵌入一个无形水印。我们还提供了一个脚本，可以方便地检测该水印。请注意，此水印与先前的 Stable Diffusion 1.x\u002F2.x 版本中的水印并不相同。\n\n要运行该脚本，您需要按照上述方式安装好相关依赖，或者尝试仅使用最少数量的包进行一项_实验性_导入：\n\n```bash\npython -m venv .detect\nsource .detect\u002Fbin\u002Factivate\n\npip install \"numpy>=1.17\" \"PyWavelets>=1.1.1\" \"opencv-python>=4.1.0.25\"\npip install --no-deps invisible-watermark\n```\n\n要运行脚本，您需要先按照上述方法完成安装。之后可以通过以下方式使用该脚本（请务必提前激活您的虚拟环境，例如 `source .pt1\u002Fbin\u002Factivate`）：\n\n```bash\n# 测试单个文件\npython scripts\u002Fdemo\u002Fdetect.py \u003C您的文件名>\n# 同时测试多个文件\npython scripts\u002Fdemo\u002Fdetect.py \u003C文件1> \u003C文件2> ... \u003C文件n>\n# 测试特定文件夹中的所有文件\npython scripts\u002Fdemo\u002Fdetect.py \u003C您的文件夹名>\u002F*\n```\n\n## 训练：\n\n我们在 `configs\u002Fexample_training` 中提供了示例训练配置。要启动训练，请运行以下命令：\n\n```\npython main.py --base configs\u002F\u003Cconfig1.yaml> configs\u002F\u003Cconfig2.yaml>\n```\n\n其中配置文件将从左到右依次合并（后面的配置会覆盖前面相同的值）。这可用于组合模型、训练和数据配置。不过，也可以将所有内容定义在一个单独的配置文件中。例如，要在 MNIST 数据集上运行基于像素的条件扩散模型训练，可执行以下命令：\n\n```bash\npython main.py --base configs\u002Fexample_training\u002Ftoy\u002Fmnist_cond.yaml\n```\n\n**注1：** 使用非玩具数据集的配置文件 `configs\u002Fexample_training\u002Fimagenet-f8_cond.yaml`、`configs\u002Fexample_training\u002Ftxt2img-clipl.yaml` 和 `configs\u002Fexample_training\u002Ftxt2img-clipl-legacy-ucg-training.yaml` 进行训练时，需根据所用数据集进行相应修改（预计数据将以 tar 文件形式存储在 [webdataset 格式](https:\u002F\u002Fgithub.com\u002Fwebdataset\u002Fwebdataset) 中）。要找到需要调整的部分，请在相应配置文件中搜索包含 `USER:` 的注释。\n\n**注2：** 本仓库同时支持 `pytorch1.13` 和 `pytorch2` 用于生成模型的训练。然而，对于自编码器训练，例如在 `configs\u002Fexample_training\u002Fautoencoder\u002Fkl-f4\u002Fimagenet-attnfree-logvar.yaml` 中所示，仅支持 `pytorch1.13`。\n\n**注3：** 训练潜在空间生成模型（如 `configs\u002Fexample_training\u002Fimagenet-f8_cond.yaml` 所示）需要从 [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fsdxl-vae\u002Ftree\u002Fmain) 获取检查点，并替换 [此行](configs\u002Fexample_training\u002Fimagenet-f8_cond.yaml#81) 中的 `CKPT_PATH` 占位符。文本到图像的相关配置也需要进行同样的操作。\n\n### 构建新的扩散模型\n\n#### 条件器\n\n`GeneralConditioner` 通过 `conditioner_config` 进行配置。其唯一属性是 `emb_models`，即一个由不同嵌入器组成的列表（均继承自 `AbstractEmbModel`），用于对生成模型进行条件化。所有嵌入器都应定义是否可训练（`is_trainable`，默认为 `False`）、是否使用无分类器指导的丢弃率（`ucg_rate`，默认为 `0`），以及输入键（`input_key`），例如用于文本条件化的 `txt` 或用于类别条件化的 `cls`。在计算条件时，嵌入器会以 `batch[input_key]` 作为输入。我们目前支持二维至四维的条件，并会适当地将不同嵌入器的条件拼接在一起。请注意，`conditioner_config` 中嵌入器的顺序非常重要。\n\n#### 网络\n\n神经网络通过 `network_config` 进行设置。过去这一部分被称为 `unet_config`，但不够通用，因为我们计划尝试基于 Transformer 的扩散骨干网络。\n\n#### 损失\n\n损失函数通过 `loss_config` 进行配置。对于标准的扩散模型训练，您需要设置 `sigma_sampler_config`。\n\n#### 采样器配置\n\n如上所述，采样器与模型无关。在 `sampler_config` 中，我们会设置数值求解器类型、步数、离散化方式，以及例如用于无分类器指导的引导包装器等参数。\n\n### 数据集处理\n\n对于大规模训练，我们建议使用来自我们 [datapipelines](https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines) 项目的数据管道。该项目已包含在依赖项中，并在遵循[安装部分](#installation)步骤时自动引入。小型映射风格的数据集应在本仓库中定义（例如 MNIST、CIFAR-10 等），并返回一个包含数据键值的字典，例如：\n\n```python\nexample = {\"jpg\": x,  # 这是一个 -1...1 范围内的 chw 格式张量\n           \"txt\": \"一张美丽的图片\"}\n```\n\n我们期望图像以 -1 到 1 的范围、通道优先的格式提供。","# Generative Models 快速上手指南\n\n本指南基于 Stability AI 开源的 `generative-models` 仓库，重点介绍最新发布的 **SV4D 2.0**（视频转 4D）及 **SV3D**（图片转多视角视频）模型的快速部署与推理。\n\n## 1. 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐) 或 macOS\n*   **Python 版本**: Python 3.10\n*   **GPU**: 支持 CUDA 的 NVIDIA 显卡（建议显存 ≥ 16GB，低显存需开启优化参数）\n*   **CUDA 版本**: 建议 11.8 或更高（需与 PyTorch 版本匹配）\n\n## 2. 安装步骤\n\n### 2.1 创建虚拟环境并安装依赖\n\n建议使用 `venv` 隔离环境。以下命令将创建环境并安装 PyTorch（CUDA 11.8 版本）及项目所需依赖。\n\n> **注意**：国内用户若下载 PyTorch 较慢，可尝试使用清华源或中科大源替换 pip 源，但 PyTorch 官方 wheel 包建议尽量从官方源获取以保证兼容性。\n\n```bash\n# 创建虚拟环境\npython3.10 -m venv .generativemodels\n\n# 激活环境\nsource .generativemodels\u002Fbin\u002Factivate\n\n# 安装 PyTorch (根据实际 CUDA 版本调整 index-url，此处为 cu118)\npip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n\n# 安装项目核心依赖\npip3 install -r requirements\u002Fpt2.txt\n\n# 安装当前包\npip3 install .\n\n# 安装 Stability AI 数据管道依赖\npip3 install -e git+https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fdatapipelines.git@main#egg=sdata\n```\n\n### 2.2 下载模型权重\n\n模型权重需从 Hugging Face 下载并存放于 `checkpoints\u002F` 目录。\n\n> **提示**：国内访问 Hugging Face 可能受限，建议使用镜像站（如 `hf-mirror.com`）或代理加速。\n> 设置环境变量使用镜像：`export HF_ENDPOINT=https:\u002F\u002Fhf-mirror.com`\n\n#### 下载 SV4D 2.0 (最新推荐)\n用于从单目视频生成高保真 4D 资产。\n```bash\n# 设置镜像加速 (可选，国内推荐)\nexport HF_ENDPOINT=https:\u002F\u002Fhf-mirror.com\n\n# 下载主模型\nhuggingface-cli download stabilityai\u002Fsv4d2.0 sv4d2.safetensors --local-dir checkpoints\n\n# (可选) 下载 8 视角版本模型\nhuggingface-cli download stabilityai\u002Fsv4d2.0 sv4d2_8views.safetensors --local-dir checkpoints\n```\n\n#### 下载 SV3D \u002F SV4D (旧版)\n若需使用旧版 SV4D 或 SV3D，需额外下载 SV3D 权重：\n```bash\nhuggingface-cli download stabilityai\u002Fsv3d sv3d_u.safetensors --local-dir checkpoints\nhuggingface-cli download stabilityai\u002Fsv3d sv3d_p.safetensors --local-dir checkpoints\nhuggingface-cli download stabilityai\u002Fsv4d sv4d.safetensors --local-dir checkpoints\n```\n\n## 3. 基本使用\n\n### 3.1 运行 SV4D 2.0 (视频转 4D)\n\n这是目前最推荐的流程，支持输入 GIF\u002FMP4 或图片序列，生成多视角视频。\n\n**基础命令：**\n```bash\npython scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path assets\u002Fsv4d_videos\u002Fcamel.gif --output_folder outputs\n```\n\n**常用参数说明：**\n*   `--input_path`: 输入路径，支持 `.gif`, `.mp4` 文件，或包含帧图片的文件夹。\n*   `--num_steps`: 采样步数，默认 50。降低此值可加快推理速度（如设为 25）。\n*   `--elevations_deg`: 指定生成的视角仰角（相对于输入视角），默认 0.0。\n*   `--remove_bg`: 若输入视频背景简单，设为 `True` 自动去除背景（需安装 `rembg`）。\n    ```bash\n    python scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path \u003Cpath\u002Fto\u002Fvideo> --remove_bg=True\n    ```\n\n**低显存优化方案：**\n若遇到 OOM (显存不足) 错误，可减少单次编码\u002F解码的帧数或降低分辨率：\n```bash\npython scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --input_path \u003Cpath\u002Fto\u002Fvideo> --encoding_t=1 --decoding_t=1 --img_size=512\n```\n\n**使用 8 视角模型：**\n```bash\npython scripts\u002Fsampling\u002Fsimple_video_sample_4d2.py --model_path checkpoints\u002Fsv4d2_8views.safetensors --input_path assets\u002Fsv4d_videos\u002Fchest.gif --output_folder outputs\n```\n\n### 3.2 运行 SV3D (图片转多视角视频)\n\n适用于从单张静态图片生成环绕视频。\n\n**运行 SV3D_u (无相机条件，生成轨道视频):**\n```bash\npython scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_u\n```\n\n**运行 SV3D_p (指定相机路径):**\n生成固定仰角的静态轨道视频：\n```bash\npython scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_p --elevations_deg 10.0\n```\n\n生成动态轨道视频（需指定 21 个仰角和方位角序列）：\n```bash\npython scripts\u002Fsampling\u002Fsimple_video_sample.py --input_path \u003Cpath\u002Fto\u002Fimage.png> --version sv3d_p --elevations_deg [\u003Clist of 21 elevations>] --azimuths_deg [\u003Clist of 21 azimuths>]\n```\n\n### 3.3 启动 Web Demo (可选)\n\n项目提供了 Streamlit 和 Gradio 演示界面，方便交互式测试。\n\n*   **SV3D\u002FSVD Streamlit Demo:**\n    ```bash\n    streamlit run scripts\u002Fdemo\u002Fvideo_sampling.py\n    ```\n*   **SV4D Gradio Demo:**\n    ```bash\n    python -m scripts.demo.gradio_app_sv4d\n    ```","一家电商视觉团队需要为新款运动相机制作 360 度产品展示视频，但仅有单角度拍摄的 12 帧素材。\n\n### 没有 generative-models 时\n- **多视角拍摄成本高昂**：必须搭建专业转盘或动用多台摄像机同步拍摄，耗时耗力且难以捕捉高速运动细节。\n- **手动建模效率低下**：若尝试通过 3D 建模软件重建物体，不仅对美术人员技术要求极高，且无法还原真实光影与材质纹理。\n- **动态一致性差**：使用传统插值算法生成的新视角视频，在物体快速转动时容易出现画面撕裂、模糊或时空闪烁。\n- **背景处理繁琐**：真实拍摄环境中的杂乱背景难以自动剥离，导致合成视频需逐帧进行复杂的后期抠图处理。\n\n### 使用 generative-models 后\n- **单视频生成 4D 资产**：直接输入一段白底单视角运动视频，SV4D 2.0 即可自动推理出包含 4 个不同相机视角的高保真 48 帧序列。\n- **细节与动态更锐利**：模型显著提升了运动过程中的清晰度，解决了以往生成视频中常见的模糊问题，确保时空高度一致。\n- **抗遮挡能力增强**：不再依赖首帧的多视角参考图，即使物体存在自遮挡，也能鲁棒地生成连贯的新视角画面。\n- **流程自动化集成**：支持结合 rembg 自动去除背景，并可通过自回归方式生成长视频，大幅简化了从素材到成品的链路。\n\ngenerative-models 将原本需要数天专业制作的 4D 内容生产，缩减为分钟级的自动化推理过程，极大降低了高动态 3D 资产的创作门槛。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FStability-AI_generative-models_8717fd2a.jpg","Stability-AI","Stability AI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FStability-AI_29f6719e.png","",null,"team-sre@stability.ai","https:\u002F\u002Fwww.stability.ai\u002F","https:\u002F\u002Fgithub.com\u002FStability-AI",[86,90],{"name":87,"color":88,"percentage":89},"Python","#3572A5",98.1,{"name":91,"color":92,"percentage":93},"Roff","#ecdebe",1.9,27078,3074,"2026-04-10T22:08:34","MIT",4,"Linux","必需 NVIDIA GPU。官方示例指定 CUDA 11.8 (cu118)。显存需求取决于分辨率和模式：默认生成 576x576 分辨率视频；低显存环境可通过设置 `--encoding_t=1`、`--decoding_t=1` 或将分辨率降至 512 (`--img_size=512`) 来运行，建议显存 8GB 以上以获得最佳效果。","未说明",{"notes":103,"python":104,"dependencies":105},"1. 安装需先创建 Python 3.10 虚拟环境。2. 必须手动从 HuggingFace 下载模型权重文件（如 sv4d2.safetensors, sv3d_u.safetensors 等）至 checkpoints 目录。3. 对于背景复杂的真实世界视频，建议预先使用 rembg、Clipdrop 或 SAM2 进行前景分割以提升生成质量。4. 项目依赖一个特定的外部数据管道库 (sdata)，需通过 git 地址安装。","3.10",[106,107,108,109],"torch","torchvision","torchaudio","sdata (Stability-AI\u002Fdatapipelines)",[16,29],"2026-03-27T02:49:30.150509","2026-04-11T15:12:02.519491",[114,119,124,129,134,139],{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},29509,"运行脚本成功但生成的 MP4 视频无法播放或显示损坏怎么办？","该问题通常由缺少视频编码依赖库引起。请尝试安装以下包来解决：\n1. 安装 imageio-ffmpeg 和 pyav：`pip install imageio-ffmpeg pyav`\n2. 如果上述方法无效，部分用户反馈切换到 cv2 也能解决问题。\n安装后重新运行脚本即可生成可正常播放的视频。","https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fissues\u002F326",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},29510,"安装依赖时出现 'Getting requirements to build wheel ... error' 或 'No module named torch' 错误如何解决？","这通常是因为构建某些包（如 tokenizers 或 xformers）需要 Rust 编译器，而系统中未安装。\n解决方案：\n1. 先安装 Rust。标准安装命令为：`curl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh`\n2. 安装完成后，重新运行 pip install 命令。\n此外，建议锁定关键包的版本以避免兼容性问题，例如在 requirements 文件中指定 `torch==2.0.1`, `xformers==0.0.20`, `numpy\u003C2.0`。","https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fissues\u002F423",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},29511,"启动 Streamlit UI 时报错 'ModuleNotFoundError: No module named scripts' 怎么办？","这是一个常见的路径导入问题。确保你在项目的根目录下运行命令，而不是在子目录中。\n正确的运行方式是在包含 `scripts` 文件夹的根目录下执行：\n`streamlit run scripts\u002Fsampling\u002Fsimple_video_sample.py`\n或者 `streamlit run scripts\u002Fdemo\u002Fsampling.py`（取决于具体入口）。\n如果仍然报错，请检查当前工作目录是否正确，或者尝试将项目根目录添加到 PYTHONPATH 环境变量中。","https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fissues\u002F169",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},29512,"加载 SDXL Autoencoder 权重时提示缺少 'post_quant_conv' 或 'quant_conv' 等键值怎么办？","发布的自动编码器权重可能与仓库中定义的模型结构不完全匹配，或者配置文件不正确。\n1. 确认你使用的 YAML 配置文件是否与权重文件对应。仓库中的示例配置（如 imagenet-attnfree-logvar.yaml）可能不是训练原始 SDXL VAE 所用的配置。\n2. 如果进行推理测试时输出全为 NaN，请检查图像预处理步骤是否正确（例如归一化范围是否为 [-1, 1]）。\n3. 社区建议参考官方发布的特定配置或使用经过验证的推理代码片段，确保模型实例化参数与权重一致。","https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fissues\u002F85",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},29513,"如何在无法直接生成有效视频的情况下获取 3D 旋转效果？","如果直接生成的视频文件损坏，可以使用 Streamlit 界面生成单帧图像作为替代方案。\n具体步骤：\n1. 运行 Streamlit 应用。\n2. 输入图片并生成旋转视角的帧图像。\n3. 虽然视频导出可能失败，但你可以保存所有生成的帧图像。\n4. 使用其他工具（如 ffmpeg）手动将这些帧图像合并成视频文件：`ffmpeg -framerate 24 -i frame_%05d.png -c:v libx264 output.mp4`。","https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fissues\u002F313",{"id":140,"question_zh":141,"answer_zh":142,"source_url":123},29514,"安装 xformers 时遇到编译错误或版本不匹配怎么办？","xformers 的安装对 PyTorch 版本和 CUDA 版本非常敏感。\n建议解决方案：\n1. 明确指定与你的 PyTorch 版本匹配的 xformers 版本。例如，对于 Torch 2.0.1，尝试安装 `xformers==0.0.20`。\n2. 确保安装了正确的 CUDA 工具包，并在安装命令中添加对应的 index-url，例如：`--extra-index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118`。\n3. 如果遇到编译错误，请务必先安装 Rust 编译器（见相关 FAQ）。\n4. 修改 requirements 文件，固定 `torch`, `torchvision`, `xformers` 和 `numpy` 的版本可以避免大部分依赖冲突。",[144,149],{"id":145,"version":146,"summary_zh":147,"released_at":148},205979,"0.1.0","## 发布\n- 发布两款采用宽松的 [CreativeML Open RAIL++-M 许可证](https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fblob\u002Fmain\u002Fmodel_licenses\u002FLICENSE-SDXL1.0) 的全新开源模型（文件哈希请参见 [推理](https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models#inference)）：\n    - [SDXL-base-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-base-1.0)：SDXL-base-0.9 的改进版本。\n    - [SDXL-refiner-1.0](https:\u002F\u002Fhuggingface.co\u002Fstabilityai\u002Fstable-diffusion-xl-refiner-1.0)：SDXL-refiner-0.9 的改进版本。\n- 关于 SDXL 的技术报告现已发布，详情请见 [这里](https:\u002F\u002Farxiv.org\u002Fabs\u002F2307.01952)。\n\n![001_with_eval](https:\u002F\u002Fgithub.com\u002FStability-AI\u002Fgenerative-models\u002Fassets\u002F62965623\u002Fe457ed1e-e688-4da9-a625-bf16ed2c5ed2)\n\n## 贡献\n- #17：使用 hatch 设置打包流程\n- #59：为 .pt13 和 .pt2 环境冻结依赖项，添加 black 代码格式化工具及自动构建测试\n- #57、#66：添加基于 pytest 的自动推理测试，并设置代码所有者\n- #69：优化推理代码\n- #68、#67、#70、#71：更新 README、许可证、模型名称及哈希值","2023-07-27T08:07:20",{"id":150,"version":151,"summary_zh":152,"released_at":153},205980,"0.0.1","- 发布 `SD-XL 0.9-base` 和 `SD-XL 0.9-refiner` 模型\n- 发布新的 `sgm` 代码库\n- 移除大量的子类化\n- 在一个单一的类 `GeneralConditioner` 中处理所有类型的条件输入（向量、序列和空间条件，以及它们的所有组合）\n- 将引导器和采样器与模型解耦，使其独立\n- 在训练和推理中均采用【去噪器框架】（https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.00364）\n- 离散时间模型是连续时间模型的特例\n- 将扩散损失函数的加权、网络的预条件化以及训练过程中噪声水平的采样等特性实现为相互独立的功能\n- 优化自动编码模型","2023-06-22T16:58:02"]