MistoLine-线条魔法,驾驭每一缕创意!

简介: MistoLine 是一个可以适配任意类型线稿,准确性高,稳定性优秀的SDXL-ControlnetNet模型。它可以基于用户输入的任意类型的线稿图(手绘、各类controlnet-line preprocessor、模型线框轮廓等)作为条件,生成高质量图像(短边大于1024px),无需再根据不同线预处理器选择不同的controlnet模型,MistoLine在各类线稿条件下都有较好的泛化能力。

MistoLine算法介绍

MistoLine 是一个可以适配任意类型线稿,准确性高,稳定性优秀的SDXL-ControlnetNet模型。它可以基于用户输入的任意类型的线稿图(手绘、各类controlnet-line preprocessor、模型线框轮廓等)作为条件,生成高质量图像(短边大于1024px),无需再根据不同线预处理器选择不同的controlnet模型,MistoLine在各类线稿条件下都有较好的泛化能力。

image.png

MistoLine采用了全新的线预处理算法(Anyline),并基于stabilityai/stable-diffusion-xl-base-1.0的Unet以及大模型训练工程上的创新,重新进行训练的Controlnet模型。MistoLine对于不同类型的线稿输入都有较好的表现,在更加复杂的场景下对于细节还原,prompt对齐,稳定性方面对比现有的Controlnet模型都有更好的表现结果。

MistoLine与lllyasviel公布的Controlnet架构保持一致,原理图如下:

image.png

image.png

更多关于ControlNet相关的介绍请参考:

More information about ControlNet can be found in the following references:

https://github.com/lllyasviel/ControlNet

https://huggingface.co/docs/diffusers/main/en/api/pipelines/controlnet_sdxl

该模型适配目前除(PlaygroundV2.5以及CosXL)之外的大部分SDXL模型,可以配合LCM以及其他ControlNet模型一并使用。

MistoLine在不同类型线稿下的表现对比

对于各种线预处理器,MistoLine均有良好的表现效果

image.png

MistoLine与其他controlnet的对比

对于现有各种sdxl的线控制controlnet,MistoLine在准确性和泛化性上表现出明显的优势

image.png

应用场景 Application examples

手绘渲染 Sketch rendering

以下案例只使用了MistoLine这个controlnet

image.png

模型渲染 Model rendering

以下案例只使用了Anyline作为预处理器以及MistoLine这个controlnet

image.png

魔搭社区最佳实践

环境配置与安装

本文主要演示的模型推理代码可在魔搭社区免费实例PAI-DSW的配置下运行(显存24G) :

点击模型右侧Notebook快速开发按钮,选择GPU环境

image.png

打开Notebook环境:

image.png

模型推理代码

from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
from diffusers.utils import load_image
from PIL import Image
from modelscope import snapshot_download
import torch
import numpy as np
import cv2
prompt = "sea turtle"
negative_prompt = 'low quality, bad quality, sketches'
image = load_image("https://modelscope.oss-cn-beijing.aliyuncs.com/resource/sea%20turtle.jpeg")
controlnet_conditioning_scale = 0.5
controlnet_dir = snapshot_download("TheMisto.ai/MistoLine")
VAE_dir = snapshot_download("AI-ModelScope/sdxl-vae-fp16-fix")
SDXL_dir = snapshot_download("AI-ModelScope/stable-diffusion-xl-base-1.0")
controlnet = ControlNetModel.from_pretrained(
    controlnet_dir,
    torch_dtype=torch.float16
)
vae = AutoencoderKL.from_pretrained(VAE_dir, torch_dtype=torch.float16)
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
    SDXL_dir,
    controlnet=controlnet,
    vae=vae,
    torch_dtype=torch.float16,
)
pipe.enable_model_cpu_offload()
image = np.array(image)
image = cv2.Canny(image, 100, 200)
image = image[:, :, None]
image = np.concatenate([image, image, image], axis=2)
image = Image.fromarray(image)
images = pipe(
    prompt, negative_prompt=negative_prompt, image=image, controlnet_conditioning_scale=controlnet_conditioning_scale,
    ).images
images[0].save(f"turtle.png")

效果展示:

在ComfyUI使用MistoLine

clone ComfyUI代码并安装环境

# #@title Environment Setup
from pathlib import Path
OPTIONS = {}
UPDATE_COMFY_UI = True  #@param {type:"boolean"}
INSTALL_COMFYUI_MANAGER = True  #@param {type:"boolean"}
INSTALL_ANIMATEDIFF = True  #@param {type:"boolean"}
INSTALL_CUSTOM_NODES_DEPENDENCIES = True  #@param {type:"boolean"}
OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI
OPTIONS['INSTALL_COMFYUI_MANAGER'] = INSTALL_COMFYUI_MANAGER
OPTIONS['INSTALL_ANIMATEDIFF'] = INSTALL_ANIMATEDIFF
OPTIONS['INSTALL_CUSTOM_NODES_DEPENDENCIES'] = INSTALL_CUSTOM_NODES_DEPENDENCIES
current_dir = !pwd
WORKSPACE = f"{current_dir[0]}/ComfyUI"
%cd /mnt/workspace/
![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI
%cd $WORKSPACE
if OPTIONS['UPDATE_COMFY_UI']:
  !echo "-= Updating ComfyUI =-"
  !git pull
if OPTIONS['INSTALL_COMFYUI_MANAGER']:
  %cd custom_nodes
  ![ ! -d ComfyUI-Manager ] && echo -= Initial setup ComfyUI-Manager =- && git clone https://github.com/ltdrdata/ComfyUI-Manager
  %cd ComfyUI-Manager
  !git pull
%cd $WORKSPACE
if OPTIONS['INSTALL_CUSTOM_NODES_DEPENDENCIES']:
  !pwd
  !echo "-= Install custom nodes dependencies =-"
  ![ -f "custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py" ] && python "custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py"

下载相关模型:

#@markdown ###Download standard resources
### SDXL
### I recommend these workflow examples: https://comfyanonymous.github.io/ComfyUI_examples/sdxl/
OPTIONS = {}
#@markdown **Models**
SDXL_1_0_BASE_AND_REFINER = True  #@param {type:"boolean"}
OPTIONS['SDXL_1_0_BASE_AND_REFINER'] = SDXL_1_0_BASE_AND_REFINER
if OPTIONS['SDXL_1_0_BASE_AND_REFINER']:
  !wget -c "https://modelscope.cn/api/v1/models/AI-ModelScope/stable-diffusion-xl-base-1.0/repo?Revision=master&FilePath=sd_xl_base_1.0.safetensors" -P ./models/checkpoints/
  !wget -c "https://modelscope.cn/api/v1/models/AI-ModelScope/stable-diffusion-xl-refiner-1.0/repo?Revision=master&FilePath=sd_xl_refiner_1.0.safetensors" -P ./models/checkpoints/
#@markdown **VAEs**
SDXL_1_0_VAE = True  #@param {type:"boolean"}
OPTIONS['SDXL_1_0_VAE'] = SDXL_1_0_VAE
if OPTIONS['SDXL_1_0_VAE']:
  !wget -c "https://modelscope.cn/api/v1/models/AI-ModelScope/sdxl-vae-fp16-fix/repo?Revision=master&FilePath=diffusion_pytorch_model.safetensors" -O ./models/vae/sdxl-vae-fp16-fix.safetensors #sdxl-vae-fp16-fix.safetensors
#@markdown **Controlnets**
!wget -c "https://modelscope.cn/api/v1/models/TheMisto.ai/MistoLine/repo?Revision=master&FilePath=mistoLine_rank256.safetensors" -P /mnt/workspace/ComfyUI/models/controlnet/

使用Cloudflared生成链接

!wget "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/cloudflared-linux-amd64.deb"
!dpkg -i cloudflared-linux-amd64.deb
%cd /mnt/workspace/ComfyUI
import subprocess
import threading
import time
import socket
import urllib.request
def iframe_thread(port):
  while True:
      time.sleep(0.5)
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      result = sock.connect_ex(('127.0.0.1', port))
      if result == 0:
        break
      sock.close()
  print("\nComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\n")
  p = subprocess.Popen(["cloudflared", "tunnel", "--url", "http://127.0.0.1:{}".format(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  for line in p.stderr:
    l = line.decode()
    if "trycloudflare.com " in l:
      print("This is the URL to access ComfyUI:", l[l.find("http"):], end='')
    #print(l, end='')
threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()
!python main.py --dont-print-server

导入controlnet流程,推荐工作流下载链接:

https://modelscope.oss-cn-beijing.aliyuncs.com/resource/CN_mistoline.json

ComfyUI 推荐配置

sampler steps:30
CFG:7.0
sampler_name:dpmpp_2m_sde
scheduler:karras
denoise:0.93
controlnet_strength:1.0
stargt_percent:0.0
end_percent:0.9

ComfyUI使用示例:

image.png


点击链接直达开源

https://modelscope.cn/models/TheMisto.ai/MistoLine/summary

相关文章
|
SQL 分布式计算 大数据
大数据Hive DML-Load加载数据
大数据Hive DML-Load加载数据
501 0
|
3月前
|
人工智能 JavaScript 机器人
QQ接入openclaw 保姆级教程
不用代码基础,不用复杂配置,低成本使用windows电脑安装openclaw,接入QQ机器人,实现轻松养龙虾,让QQ变成你的AI智能助手。
1307 5
|
JSON API 数据格式
深入研究:1688商品评论API详解
本文介绍如何通过第三方数据服务平台获取1688商品评论数据。由于1688官方未提供通用评论API,商家和研究人员可借助第三方接口分析消费者反馈、优化产品与服务。使用时需注册账号获取API Key,并通过必要参数(如商品ID、页码等)调用接口,返回JSON格式的评论数据。文中提供了Python示例代码,利用`requests`库发送请求,帮助用户快速上手,注意根据实际平台调整API地址和参数。
506 12
|
人工智能 算法 物联网
ComfyUI:搭积木一样构建专属于自己的AIGC工作流(保姆级教程)
通过本篇文章,你可以了解并实践通过【ComfyUI】构建自己的【文生图】和【文生动图】工作流。
24667 5
ComfyUI:搭积木一样构建专属于自己的AIGC工作流(保姆级教程)
|
12月前
|
存储 弹性计算 API
阿里云ESSD AutoPL云盘解析:特点、场景、规格及计费解析参考
阿里云ESSD AutoPL云盘以ESSD云盘为基础构建,它在延续ESSD云盘原有各项功能与卓越性能的基础上,创新性地实现了云盘容量和性能的分离。这意味着,您在为ESSD AutoPL云盘配置存储容量时,能够依据实际业务需求,灵活自定义云盘的预配置性能以及性能突发模式。本文将围绕ESSD AutoPL云盘展开详细阐述,涵盖其特点、适用应用场景、具体规格、所支持的实例规格族、计费规则,以及配置和计费方面的示例,以供大家更详细了解这一云盘产品。
|
11月前
|
编解码 物联网 开发者
FLUX.1 Kontext 的全生态教程来啦!AIGC专区在线试玩!
Flux.1 Kontext [dev] 开源模型大家都用上了吗?小编汇总了3个使用教程,打包送上!
3694 1
|
机器学习/深度学习 传感器 人工智能
《智启工业新篇:人工智能驱动的故障预测性维护》
在工业生产中,机器设备的稳定运行至关重要。传统维护模式存在滞后性和不确定性,导致高昂成本和风险。随着人工智能技术兴起,故障预测性维护成为可能。通过传感器采集数据,利用机器学习和深度学习算法,AI能提前预判故障,提高生产效率和安全性。工业物联网(IIoT)进一步增强了实时监控与远程管理能力,使得维护更加智能化、精准化。尽管面临数据安全和模型解释性等挑战,AI驱动的预测性维护正逐步改变传统模式,引领工业生产迈向更智能、高效的新时代。
1370 18
|
存储 监控 芯片
单片机的扩展结构
单片机的扩展结构
967 2
|
人工智能 JSON Serverless
AI “黏土画风”轻松拿捏,手把手带你云端部署 ComfyUI
ComfyUI 是一款基于节点工作流稳定扩散算法的全新 WebUI,相对于传统的 WebUI,ComfyUI 的部署和学习曲线较陡峭,函数计算基于 Serverless 应用中心开发“ComfyUI 应用模版”,简化开发者的部署流程,帮助简单、快捷实现全新而精致的绘画体验,点击本文查看一键部署 ComfyUI 的方法。
21220 7

热门文章

最新文章