码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • sd-webui-controlnet代码分析


    controlnet前向代码解析_Kun Li的博客-CSDN博客文章浏览阅读1.5k次。要分析下controlnet的yaml文件,在params中分成了4个部分,分别是control_stage_config、unnet_config、first_stage_config、cond_stage_config。其中control_stage_config对应的是13层的controlnet,unet_config对应的是diffusion model,first_stage_config对应的是vae中的decode部分。cldm:controlnet版本的ldm。https://blog.csdn.net/u012193416/article/details/129956546?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522170028636116800188569967%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=170028636116800188569967&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-3-129956546-null-null.nonecase&utm_term=controlnet&spm=1018.2226.3001.4450上面是之前写的controlnet原版的代码流程。

    stable-diffusion-webui源码分析(7)-controlnet - 知乎AUTOMATIC1111的stable-diffusion-webui是近期很流行的stable-diffusion界面应用,它集合stable-diffusion各项常用功能,还通过扩展的形式支持controlnet、lora等技术。分析它的源码,也在一定程度上有助于理解sta…icon-default.png?t=N7T8https://zhuanlan.zhihu.com/p/620218436上面介绍的还是挺详细的。

    1. api.py->这个api和alwayson_scripts不同
    2. controlnet_ui/controlnet_ui_group.UiControlNetUnit->internal_controlnet/external_code.ControlNetUnit
    3. controlnet.py->
    4. ui->
    5. self.ui_group->
    6. ControlNetUiGroup->
    7. controlnet_ui/controlnet_ui_group.ControlNetGroup->render()
    8. controlnet.py->process()->
    9. unet = p.sd_model.model.diffusion_model->
    10. unit.module = global_state.get_module_basename(unit.module)
    11. resize_mode = external_code.resize_mode_from_value(unit.resize_mode)
    12. control_mode = external_code.control_mode_from_value(unit.control_mode)->
    13. model_net = Script.load_control_model(p, unet, unit.model, unit.low_vram)->
    14. input_image, image_from_a1111 = Script.choose_input_image(p, unit, idx)->
    15. preprocessor = self.preprocessor[unit.module]->
    16. detected_map, is_image = preprocessor(input_image,res=preprocessor_resolution,thr_a=unit.threshold_a,thr_b=unit.threshold_b) ->
    17. control, detected_map = Script.detectmap_proc(detected_map, unit.module, resize_mode, h, w) ->
    18. control_model_type = ControlModelType.ControlNet->
    19. preprocessor_dict = dict()->
    20. forward_param = ControlParams()->
    21. self.latest_network = UnetHook(lowvram=any(unit.low_vram for unit in self.enabled_units))->
    22. self.latest_network.hook(model=unet, sd_ldm=sd_ldm, control_params=forward_params, process=p)
    23. - hook.py->UnetHook()->
    24. - process.sample = process_sample
    25. - model._original_forward = model.forward
    26. - model.forward = forward_webui.__get__(model,UNetModel) # 重新给model.foward赋值
    27. -- forward(*args,**kwargs)->
    28. -- # handle cond-uncond marker
    29. -- # convert control image to latent
    30. -- # handle prompt token control
    31. -- # handle controlnet
    32. -- # replace x_t to support inpaint models
    33. -- # clear attention and adain cache
    34. -- # unet encoder
    35. -- # unet middle block
    36. -- # unet decoder
    37. -- # unet output
    38. -- # post-processing for color fix
    39. -- # post-processing for restore
    40. scripts.script_callbacks.on_cfg_denoiser(self.guidance_schedule_handler)

    Tips:

    最大的问题,controlnet的on_ui_setting并没有被启用?

    [Bug]: on_ui_settings callback gets called after "ui" method in scripts · Issue #11210 · AUTOMATIC1111/stable-diffusion-webui · GitHub

    大概是这么个问题,就是我在插件中写的on_ui_setting注入到webui中,再从插件中使用这些注入的参数时,无效,需要在安装完后,执行reload操作,这样这些参数注入才是有效的?

    但是on_ui_setting中的参数多是默认参数,其实也不太影响。

  • 相关阅读:
    算法基础2暴力递归
    RabbitMQ:发布确认模式
    开源短剧付费变现小程序源码系统+在线开通会员+在线充值 带完整的搭建教程
    21年-05-自研-自我准备
    vue 部署到nginx 刷新404
    Mybatis(动态sql和分页)
    MyBatis(二、基础进阶)
    Splunk iowait 报警的解决
    不重装系统,如何将系统从SSD迁移到M2固态硬盘
    MinIO:开源对象存储解决方案的领先者
  • 原文地址:https://blog.csdn.net/u012193416/article/details/134477491
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号