又双叒叕种草了新家装风格?AI 帮你家居换装
本文分享自华为云社区《又双叒叕种草了新家装风格?AI帮你家居换装!》,作者:Emma_Liu。
你是否曾经想过,如果能够轻松地看到自己家居的不同风格,该有多好呢?现在,这一切都变得可能了!
让你的眼睛仔细观察这些图片,你会发现它们展现了不同的风格和氛围,从现代简约到古典优雅,从温馨舒适到时尚前卫,应有尽有。但是,你知道吗?这些图片都是由 AI 生成的!

它们看起来非常逼真,仿佛是真实的照片一样。这就是人工智能的奇妙之处,让我们可以轻松地预览不同的家居风格,不必实际进行装修。让我们一起来感受 AI 技术的魅力吧!
装修风格参考

现代极简风卧室
图一是原图,我要基于图一的装修布局重新装修一下,图二是 M-LSD 线段检测器的输出图像,图三是加入 prompt 为:现代极简风卧室生成图像,图四再补充一些 prompt:现代极简风卧室,床是黄色的,墙是浅咖色。不得不说效果真不错!

卫生间
图一这种简单布局的卫生间我很是喜欢,康康其他风格的侘寂风卫生间 - 图二、三

客厅
换装 ing 奶油风客厅无名(不填 prompt 也可以生成不错的图片,很多惊喜诶)

别墅
我已经在幻想住上大别墅了看看别墅的效果怎么样浪漫的海边别墅——新中式别墅

我想尝试用建筑设计图来看看能不能生成…哇,绝绝子简约风、现代风

其他建筑
建模图变——欧式建筑

厂房变办公楼、大型超市、别墅(这样式的别墅)

好神奇,它是怎么做到的呢,来看看模型的介绍。
0.模型介绍
建筑的稳定扩散 | ControlNet 模型-MLSD,随意创建建筑物、房间内部或外部以及独特的场景
ControlNet 最早是在 L.Zhang 等人的论文《Adding Conditional Control to Text-to-Image Diffusion Model》中提出的,目的是提高预训练的扩散模型的性能。它引入了一个框架,支持在扩散模型 (如 Stable Diffusion ) 上附加额外的多种空间语义条件来控制生成过程。为稳定扩散带来了前所未有的控制水平。
Mobile LSD (M-LSD): 《Towards Light-weight and Real-time Line Segment Detection》是用于资源受限环境的实时和轻量级线段检测器,M-LSD 利用了极其高效的 LSD 体系结构和新的训练方案,包括 SoL 增强和几何学习方案。模型可以在 GPU、CPU 甚至移动设备上实时运行。


案例已分享至 AI Gallery - AI建筑风格修改: ControlNet-MLSD,一起来运行代码,实现你的新装吧。
1. 装包
2. 下载模型
使用 mlsd, sd-controlnet-mlsd, stable-diffusion-v1-5 预训练模型,为方便大家使用,已转存到华为云 OBS 中。
3. 加载模型
4. 生成图像
首先,传入的图片会通过 mlsd detector 输出黑白线条图,然后基于此 mlsd 图像,通过 controlnet 和 stable diffusion 生成图像。
5. Gradio 可视化部署
Gradio 应用启动后可在下方页面上传图片根据提示生成图像,您也可以分享 public url 在手机端,PC 端进行访问生成图像。
参数说明
img_path:输入图像路径
prompt:提示词(建议填写)
n_prompt: 负面提示(可选)
num_inference_steps: 采样步数,一般 15-30,值越大越精细,耗时越长
image_resolution: 对输入的图片进行最长边等比 resize
detect_resolution:Hough Resolution,检测分辨率,值越小-线条越粗糙
value_threshold: Hough value threshold (MLSD),值越大-检测线条越多,越详细
distance_threshold: Hough distance threshold (MLSD),值越大-距离越远,检测到的线条越少
对比一下参数 value_threshold,distance_threshold,当 value_threshold 值变大时,如图二所示,检测到的线段越少,获取到的信息也就越少,对控制生成后的图像来说,会缺失掉很多的细节;当 distance_threshold 值变大时,如图三所示,越远处的物体,提取到的线段越少,图像会更专注于前面的部分。这对于来调整生成的图像是一个很好的参考。

参考文献
Paper: 《Adding Conditional Control to Text-to-Image Diffusion Model》
Paper: 《Towards Light-weight and Real-time Line Segment Detection》
Model:sd-controlnet-mlsd, stable-diffusion-v1-5
案例代码地址:AI Gallery - AI建筑风格修改: ControlNet-MLSD 免费体验
版权声明: 本文为 InfoQ 作者【华为云开发者联盟】的原创文章。
原文链接:【http://xie.infoq.cn/article/2130ae3e9a82a6f9c2275adb2】。文章转载请联系作者。
评论