当前位置: 首页 > news >正文

网站建设客户怎么寻找永川网站建设熊掌号

网站建设客户怎么寻找,永川网站建设熊掌号,营销型和展示型网站,建站平台的基础概念使用diffusers 加载 LoRA,实现文生图功能。摘自 diffusers文档。 模型可以根据名称去modelscope找对应资源下载。使用的时候需要替换成具体路径。虽然modelscope和diffusers都使用了模型id,但是并不能通用。 不同的LoRA对应了不同的“trigger” words&am…

使用diffusers 加载 LoRA,实现文生图功能。摘自 diffusers文档。
模型可以根据名称去modelscope找对应资源下载。使用的时候需要替换成具体路径。虽然modelscope和diffusers都使用了模型id,但是并不能通用。
不同的LoRA对应了不同的“trigger” words,在prompt中加入这个“trigger” words才能生成正确的结果。
比如使用了toy-face的LoRA模型,那么就要在prompt加入“toy face”。

from diffusers import DiffusionPipeline
import torchpipe_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipe = DiffusionPipeline.from_pretrained(pipe_id, torch_dtype=torch.float16).to("cuda")#模型下载
#from modelscope import snapshot_download
#model_dir = snapshot_download('SDXL-LoRA/CiroN2022-toy-face')
#加载lora
pipe.load_lora_weights("CiroN2022/toy-face", weight_name="toy_face_sdxl.safetensors", adapter_name="toy")
# 加入 “toy face”
prompt = "toy_face of a hacker with a hoodie"
lora_scale = 0.9
image = pipe(prompt, num_inference_steps=30, cross_attention_kwargs={"scale": lora_scale}, generator=torch.manual_seed(0)
).images[0]
image

也可以再加载另一个模型,pipe.set_adapters() 函数确定使用哪个模型。不同的模型根据adapter_name来区分。

pipe.load_lora_weights("nerijs/pixel-art-xl", weight_name="pixel-art-xl.safetensors", adapter_name="pixel")
pipe.set_adapters("pixel")prompt = "a hacker with a hoodie, pixel art"
image = pipe(prompt, num_inference_steps=30, cross_attention_kwargs={"scale": lora_scale}, generator=torch.manual_seed(0)
).images[0]
image

也可以同时使用,adapter_weights设置不同的权重,prompt也应该包括全部的“trigger” words。

pipe.set_adapters(["pixel", "toy"], adapter_weights=[0.5, 1.0])
prompt = "toy_face of a hacker with a hoodie, pixel art"
image = pipe(prompt, num_inference_steps=30, cross_attention_kwargs={"scale": 1.0}, generator=torch.manual_seed(0)
).images[0]
image

在这里插入图片描述

更准确的控制LoRA的影响强度。unet一般包括down、mid、up,不同的部分对图片的细节、纹理、风格等影响不同。

pipe.enable_lora()  # enable lora again, after we disabled it above
prompt = "toy_face of a hacker with a hoodie, pixel art"
adapter_weight_scales = { "unet": { "down": 1, "mid": 0, "up": 0} }
pipe.set_adapters("pixel", adapter_weight_scales)
image = pipe(prompt, num_inference_steps=30, generator=torch.manual_seed(0)).images[0]
image

从左到右分别对应{ “down”: 1, “mid”: 0, “up”: 0},{ “down”: 0, “mid”: 1, “up”: 0},{ “down”: 0, “mid”: 0, “up”: 1}
在这里插入图片描述

更细粒度的控制。要根据具体的模型结构,不同的模型结构不同。

adapter_weight_scales_toy = 0.5
adapter_weight_scales_pixel = {"unet": {"down": 0.9,  # all transformers in the down-part will use scale 0.9# "mid"  # because, in this example, "mid" is not given, all transformers in the mid part will use the default scale 1.0"up": {"block_0": 0.6,  # all 3 transformers in the 0th block in the up-part will use scale 0.6"block_1": [0.4, 0.8, 1.0],  # the 3 transformers in the 1st block in the up-part will use scales 0.4, 0.8 and 1.0 respectively}}
}
pipe.set_adapters(["toy", "pixel"], [adapter_weight_scales_toy, adapter_weight_scales_pixel])
image = pipe(prompt, num_inference_steps=30, generator=torch.manual_seed(0)).images[0]
image

在这里插入图片描述

常用函数

#不使用
pipe.disable_lora()
#使用
pipe.enable_lora()
#正在使用的
pipe.get_active_adapters()
#列表
pipe.get_list_adapters()
#删除
pipe.delete_adapters("toy")
http://www.yayakq.cn/news/199903/

相关文章:

  • sqlite3做网站数据库网站开发必须要用js
  • 深圳网站建设需要多少费用爬取1024上传到wordpress
  • dw网站站点正确建设方式网站管理员怎么做联系方式
  • 大学生兼职网站开发深圳宝安高端网站建设报价
  • 建销售网站需要多少钱网站上线模板
  • 能免费做微信群推广的网站青岛做模板网站的公司
  • 商派商城网站建设公司2021智慧树互联网与营销创新
  • 企业邮箱格式范本新余seo
  • 武昌做网站公司中国工程建设信息网官网查询
  • 知名自助建站平台北京经济适用房
  • 网站建设需要有什么特点河北省住房与建设厅网站首页
  • 工商注册官方网站重庆公司网站建设
  • 南京网站南京网站设计制作公司织梦安装教程
  • vs2010网站开发源码快速收录域名
  • 网站建设面试常见问题西杰网站建设
  • 网站制作ppt模板找工作 招聘附近8小时双休
  • 网站文章的作用英文网站建设网站
  • 怎么调查建设网站网页传奇游戏端游人气第一
  • 建设银行陕西分行网站网站关键词堆砌
  • 广州网络帮助建站无法打开wordpress网页
  • 织梦中英网站怎么做网站电脑基础培训班
  • 网站的建设原始代码网络营销是一种无媒介销售
  • 网站移动端怎么做的网站运营与管理试卷
  • 网站设计怎么保持风格一致用wix做外贸网站
  • hugo 怎么做网站wordpress文章视频模板
  • 南宁 网站设计医院网站建设需要注意什么
  • 网站建设 实训题网站全局参数设置
  • 网站建设用什么开源程序好网站建设工作进度
  • dede分类信息网站手机上如何做微电影网站
  • 广州网站建设联系电话效果图网站无缝连接