扩散模型的无缝分辨率适配器
ResAdapter是一款轻量级分辨率适配器,可集成至各类扩散模型中实现任意分辨率图像生成。无需额外训练和推理,ResAdapter通过少量参数(SD1.5为0.9M, SDXL为0.5M)支持广泛的分辨率范围。项目提供使用指南、预训练权重及与多种模型的集成示例,展示了其在文本生成图像和图像编辑等任务中的应用效果。
程家祥、谢盼*、夏鑫、李嘉实、吴杰、任宇熙、李慧霞、肖雪峰、郑敏、傅联(*通讯作者)
字节跳动自动机器学习部门
⭐ 如果ResAdapter对您的图像或项目有帮助,请给这个仓库点个星。谢谢!🤗
<a href='https://res-adapter.github.io/'><img src='https://img.shields.io/badge/项目-主页-green'></a>
<a href='https://arxiv.org/abs/2403.02084'><img src='https://img.shields.io/badge/论文-Arxiv-red'></a>
<a href='https://huggingface.co/papers/2403.02084'><img src='https://img.shields.io/badge/论文-Huggingface-blue'></a>
我们提出了ResAdapter,一个即插即用的分辨率适配器,可以使任何扩散模型生成自由分辨率的图像:无需额外训练,无需额外推理,无需风格迁移。
<img src="https://yellow-cdn.veclightyear.com/835a84d5/7d1aaeda-3071-48c9-9a40-7aaeec63e34f.png" width="49.9%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/60d857ab-7356-4f03-be08-d95631c7f348.png" width="50%"> ResAdapter与dreamlike-diffusion-1.0的对比示例。
</div>[2024/04/07]
🔥 我们在Huggingface上发布了官方gradio空间。[2024/04/05]
🔥 我们发布了resadapter_v2权重。[2024/03/30]
🔥 我们发布了ComfyUI-ResAdapter。[2024/03/28]
🔥 我们发布了resadapter_v1权重。[2024/03/04]
🔥 我们发布了arxiv论文。我们提供了一个独立的示例代码,帮助您快速使用ResAdapter与扩散模型。
<div align=center> <img src="https://yellow-cdn.veclightyear.com/835a84d5/6079af7b-b7ab-4122-9d91-2873d155632c.png" width="100%"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/80f98e9b-69d7-436b-90fc-1748c24df9ff.png" width="100%">ResAdapter与dreamshaper-xl-1.0的对比示例(640x384)。上:使用ResAdapter。下:不使用ResAdapter。
</div># pip install diffusers, transformers, accelerate, safetensors, huggingface_hub import torch from torchvision.utils import save_image from safetensors.torch import load_file from huggingface_hub import hf_hub_download from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler generator = torch.manual_seed(0) prompt = "肌肉发达的胡子男子的肖像照片,穿着破旧的机甲装,轻微散景,复杂精致,钢铁质感,优雅,清晰聚焦,柔和光线,鲜艳色彩" width, height = 640, 384 # 加载基准管道 model_name = "lykon-models/dreamshaper-xl-1-0" pipe = AutoPipelineForText2Image.from_pretrained(model_name, torch_dtype=torch.float16, variant="fp16").to("cuda") pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++") # 基准管道推理 image = pipe(prompt, width=width, height=height, num_inference_steps=25, num_images_per_prompt=4, output_type="pt").images save_image(image, f"image_baseline.png", normalize=True, padding=0) # 为基准加载ResAdapter resadapter_model_name = "resadapter_v1_sdxl" pipe.load_lora_weights( hf_hub_download(repo_id="jiaxiangc/res-adapter", subfolder=resadapter_model_name, filename="pytorch_lora_weights.safetensors"), adapter_name="res_adapter", ) # 加载LoRA权重 pipe.set_adapters(["res_adapter"], adapter_weights=[1.0]) pipe.unet.load_state_dict( load_file(hf_hub_download(repo_id="jiaxiangc/res-adapter", subfolder=resadapter_model_name, filename="diffusion_pytorch_model.safetensors")), strict=False, ) # 加载归一化权重 # ResAdapter管道推理 image = pipe(prompt, width=width, height=height, num_inference_steps=25, num_images_per_prompt=4, output_type="pt").images save_image(image, f"image_resadapter.png", normalize=True, padding=0)
我们已发布所有ResAdapter权重,您可以从Huggingface下载ResAdapter模 型。以下是我们的ResAdapter模型卡:
模型 | 参数量 | 分辨率范围 | 比例范围 | 链接 |
---|---|---|---|---|
resadapter_v2_sd1.5 | 0.9M | 128 <= x <= 1024 | 0.28 <= r <= 3.5 | 下载 |
resadapter_v2_sdxl | 0.5M | 256 <= x <= 1536 | 0.28 <= r <= 3.5 | 下载 |
resadapter_v1_sd1.5 | 0.9M | 128 <= x <= 1024 | 0.5 <= r <= 2 | 下载 |
resadapter_v1_sd1.5_extrapolation | 0.9M | 512 <= x <= 1024 | 0.5 <= r <= 2 | 下载 |
resadapter_v1_sd1.5_interpolation | 0.9M | 128 <= x <= 512 | 0.5 <= r <= 2 | 下载 |
resadapter_v1_sdxl | 0.5M | 256 <= x <= 1536 | 0.5 <= r <= 2 | 下载 |
resadapter_v1_sdxl_extrapolation | 0.5M | 1024 <= x <= 1536 | 0.5 <= r <= 2 | 下载 |
resadapter_v1_sdxl_interpolation | 0.5M | 256 <= x <= 1024 | 0.5 <= r <= 2 | 下载 |
提示1:我们根据controlnet更新了resadapter的命名格式。
提示2:如果你想将resadapter与个性化扩散模型一起使用,你应该从CivitAI下载它们。
提示3:如果你想将resadapter与ip-adapter、controlnet和lcm-lora一起使用,你应该从Huggingface下载它们。
提示4:这里有一个安装指南,用于准备环境和下载模型。
如果你想在我们的推理脚本中生成图像,你应该按照安装指南安装依赖库并下载相关模型。在填写示例配置后,你可以直接运行这个脚本。
python main.py --config /path/to/file
<img src="https://yellow-cdn.veclightyear.com/835a84d5/b3854f92-75c7-49ac-a9c8-2439445f338b.jpg" width="25%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/1b1982dc-874e-4065-b73d-bc00936c7aca.jpg" width="25%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/658e6094-8f8f-4cbc-b263-a00623c8f23f.jpg" width="25%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/86dcde3e-11ad-41e6-9a19-5d1e6cf6f0f7.jpg" width="25%"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/53998f8e-a3b2-46c3-b86c-c1ba4800d099.jpg" width="25%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/e7b1fe48-e464-41c8-88c5-cca4b96c1108.jpg" width="25%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/71d7d6c4-012d-49c0-bba3-09ffd2410494.jpg" width="25%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/4d242760-bad1-4799-8681-78188fab4ce4.jpg" width="25%">
resadapter与dreamshaper-7的对比示例(960x1104)。上:使用resadapter。下:不使用resadapter。
</div><img src="https://yellow-cdn.veclightyear.com/835a84d5/fe028df3-fda5-4c58-a7aa-45d063f7107b.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/2df31b61-879f-4545-afc7-69f2d0b872d3.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/92194734-d640-4113-a638-f2d43cce5e85.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/16fe9db8-6071-4371-9c36-023807e09909.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/8f83e800-bad4-4a0c-a7d1-59952bd21307.jpg" width="20%"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/fe028df3-fda5-4c58-a7aa-45d063f7107b.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/e3ed8e0d-2125-4760-8d5b-0ebb08f542bd.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/1fa8ebf7-1812-4233-9ba7-b1d63bbc366c.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/49622a41-6c8f-49de-baf6-bac0be0ec833.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/59bee1d1-345d-4ca3-ada7-873ac6986aab.jpg" width="20%">
resadapter与lllyasviel/sd-controlnet-canny的对比示例(840x1264)。上:使用resadapter,下:不使用resadapter。
</div>resadapter与diffusers/controlnet-canny-sdxl-1.0之间的对比示例(336x504)。上:使用resadapter,下:不使用resadapter。
</div>resadapter与h94/IP-Adapter之间的对比示例(864x1024)。上:使用resadapter,下:不使用resadapter。
</div><img src="https://yellow-cdn.veclightyear.com/835a84d5/5c08aa70-e083-4861-a0f1-fff5bdb2e20f.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/a7694e11-19a8-4c98-9f57-0f8b51203d1f.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/4c41f67f-a108-4856-a5a4-8bd5327288d9.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/efe48d56-a90c-45e4-b35b-292e93929753.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/fa62bcec-b769-473f-9031-05b9c2e4e5e0.jpg" width="20%"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/7db44a2d-8bdd-4506-9190-05dc90f918fb.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/5997a237-8240-440c-8cb5-146570d620c6.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/aa504ec8-2174-4670-8682-8aeee451dc08.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/63ad8ec0-f418-4fea-8f97-41d5335e1cff.jpg" width="20%"><img src="https://yellow-cdn.veclightyear.com/835a84d5/e2b8d51a-e031-4637-88f8-035c0c82dd37.jpg" width="20%">
resadapter与dreamshaper-xl-1.0(使用lcm-sdxl-lora)之间的对比示例(512x512)。上:使用resadapter,下:不使用resadapter。
</div>Hugging Face空间中关于res-adapter的文本到图像示例。更多信息请参考jiaxiangc/res-adapter。 <img src="https://yellow-cdn.veclightyear.com/835a84d5/2a8b2cdd-0956-4998-ba8f-b2b6e05e74c6.png">
这是一个关于ComfyUI-ResAdapter的文本到图像示例。更多关于lcm-lora、controlnet和ipadapter的示例可以在ComfyUI-ResAdapter中找到。
我正在学习如何制作WebUI扩展。
运行以下脚本:
# pip install peft, gradio, httpx==0.23.3 python app.py
如果您发现ResAdapter对您的研究和应用有用,请使用以下BibTeX引用我们:
@article{cheng2024resadapter,
title={ResAdapter: Domain Consistent Resolution Adapter for Diffusion Models},
author={Cheng, Jiaxiang and Xie, Pan and Xia, Xin and Li, Jiashi and Wu, Jie and Ren, Yuxi and Li, Huixia and Xiao, Xuefeng and Zheng, Min and Fu, Lean},
booktitle={arXiv preprint arxiv:2403.02084},
year={2024}
}
如有任何问题,请随时通过chengjiaxiang@bytedance.com或xiepan.01@bytedance.com与我们联系。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。
openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。
高分辨率纹理 3D 资产生成
Hunyuan3D-2 是腾讯开发的用于 3D 资产生 成的强大工具,支持从文本描述、单张图片或多视角图片生成 3D 模型,具备快速形状生成能力,可生成带纹理的高质量 3D 模型,适用于多个领域,为 3D 创作提供了高效解决方案。
一个具备存储、管理和客户端操作等多种功能的分布式文件系统相关项目。
3FS 是一个功能强大的分布式文件系统项目,涵盖了存储引擎、元数据管理、客户端工具等多个模块。它支持多种文件操作,如创建文件和目录、设置布局等,同时具备高效的事件循环、节点选择和协程池管理等特性。适用于需要大规模数据存储和管理的场景,能够提高系统的性能和可靠性,是分布式存储领域的优质解决方案。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号