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

win7下asp.net网站发布广州网站设计

win7下asp.net网站发布,广州网站设计,中国万网查询,什么网站可以做字体效果好使用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.ds6.com.cn/news/120338.html

相关文章:

  • 怎么快速做网站网页优化怎么做
  • 在线做投资网站网站整合营销推广
  • 可以在线做试卷的网站站长工具源码
  • 网站推广方法主要有哪些百度seo软件是做什么的
  • 房产门户网站建设百度账号管家
  • 安徽长江建设集团有限公司网站关键词优化搜索引擎
  • 一站式网站建设供应商百度手机卫士下载安装
  • 济南网站建设联系小七今日重要新闻
  • 网站源码cms站长工具seo综合查询烟雨楼
  • 计算机网络技术 网站建设网站手机版排名seo
  • 企业网站申请流程东莞推广平台有哪些
  • wordpress浏览器不兼容seo费用
  • 中小学生做的网站精准引流推广团队
  • 网站开发下载百度app官网下载安装
  • 自己做网站怎么选架构爱站工具查询
  • 房地产开发公司资质等级中和seo公司
  • 学校网站建设流程图aso优化公司
  • jsp商务网站建设成都企业网站seo技术
  • 一次性医用口罩价格绍兴seo推广
  • 深圳手机网站开发什么企业需要网络营销和网络推广
  • 娱乐网站名字企业宣传
  • 不用编程做网站阿里云com域名注册
  • 国外logo设计网站推荐产品推广计划怎么写
  • 义乌做网站多少钱查销售数据的网站
  • 北京网站优化常识太原seo关键词排名优化
  • 武汉网站快照推广如何利用网络广告进行推广
  • 网页设计html代码大全指定颜色seo 优化一般包括哪些内容
  • 企业组网设计杭州seo网站排名
  • 建立网站成本网络营销推广方式包括哪几种
  • 网站推广做百度还是360seo公司关键词