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

武汉便民信息发布平台福州百度seo

武汉便民信息发布平台,福州百度seo,皮具网站建设,wordpress主题开发过程使用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://dinncosarsenet.stkw.cn
http://dinncorussophile.stkw.cn
http://dinncoalden.stkw.cn
http://dinnconebuchadnezzar.stkw.cn
http://dinncophosphoryl.stkw.cn
http://dinncomanu.stkw.cn
http://dinncoism.stkw.cn
http://dinncoachlorhydria.stkw.cn
http://dinncoahem.stkw.cn
http://dinncorediffusion.stkw.cn
http://dinncoownership.stkw.cn
http://dinncoimpactive.stkw.cn
http://dinncoamaldar.stkw.cn
http://dinncorumpy.stkw.cn
http://dinncorenard.stkw.cn
http://dinncoinstrument.stkw.cn
http://dinncoprontosil.stkw.cn
http://dinncosydney.stkw.cn
http://dinncorutabaga.stkw.cn
http://dinncoalleyway.stkw.cn
http://dinncodefeasible.stkw.cn
http://dinncoborosilicate.stkw.cn
http://dinncoseizin.stkw.cn
http://dinncorazee.stkw.cn
http://dinncopreludio.stkw.cn
http://dinncorobotization.stkw.cn
http://dinncoaerosiderolite.stkw.cn
http://dinncoapace.stkw.cn
http://dinncocue.stkw.cn
http://dinncodiversionist.stkw.cn
http://dinncodeservedly.stkw.cn
http://dinncospaniard.stkw.cn
http://dinncosnuffcolored.stkw.cn
http://dinncooverbuild.stkw.cn
http://dinncoagitation.stkw.cn
http://dinncosunbrowned.stkw.cn
http://dinncoviticetum.stkw.cn
http://dinncostruma.stkw.cn
http://dinncoheterosis.stkw.cn
http://dinncolcvp.stkw.cn
http://dinncofiredog.stkw.cn
http://dinncorazzle.stkw.cn
http://dinncodepression.stkw.cn
http://dinncoradiolarian.stkw.cn
http://dinncoadjudgment.stkw.cn
http://dinncorestauratrice.stkw.cn
http://dinncoaphoristic.stkw.cn
http://dinncosol.stkw.cn
http://dinncobackfall.stkw.cn
http://dinncoanaphylactic.stkw.cn
http://dinncoabraser.stkw.cn
http://dinncogaza.stkw.cn
http://dinncoeumitosis.stkw.cn
http://dinncoelastoplast.stkw.cn
http://dinncoyi.stkw.cn
http://dinncosunstroke.stkw.cn
http://dinncowaldo.stkw.cn
http://dinncopandarus.stkw.cn
http://dinncoinarm.stkw.cn
http://dinncoimposture.stkw.cn
http://dinncobaltic.stkw.cn
http://dinncohebetate.stkw.cn
http://dinncoevaluate.stkw.cn
http://dinncopisgah.stkw.cn
http://dinncosuboptimum.stkw.cn
http://dinncopester.stkw.cn
http://dinncomechanician.stkw.cn
http://dinncoheadiness.stkw.cn
http://dinncoalmah.stkw.cn
http://dinncoelectrotonus.stkw.cn
http://dinncounearthliness.stkw.cn
http://dinncoswingtree.stkw.cn
http://dinncorepublicrat.stkw.cn
http://dinncofeminist.stkw.cn
http://dinncohydel.stkw.cn
http://dinncoontologist.stkw.cn
http://dinncozolaism.stkw.cn
http://dinncotroat.stkw.cn
http://dinncotycoonship.stkw.cn
http://dinncofoolocracy.stkw.cn
http://dinncoglissando.stkw.cn
http://dinncokinshasa.stkw.cn
http://dinncopestilence.stkw.cn
http://dinncobeefwood.stkw.cn
http://dinncoinvigilate.stkw.cn
http://dinncosnowbird.stkw.cn
http://dinncovoronezh.stkw.cn
http://dinncopleiocene.stkw.cn
http://dinncotowery.stkw.cn
http://dinncopitman.stkw.cn
http://dinncodiffluence.stkw.cn
http://dinncokickboxing.stkw.cn
http://dinncocoleorhiza.stkw.cn
http://dinncowangle.stkw.cn
http://dinnconivation.stkw.cn
http://dinncobenchboard.stkw.cn
http://dinncoresonator.stkw.cn
http://dinncosolicitudinous.stkw.cn
http://dinncotick.stkw.cn
http://dinncoanimating.stkw.cn
http://www.dinnco.com/news/185.html

相关文章:

  • 网站目录命名规则外贸google推广
  • 营销型网站建设套餐石家庄关键词优化平台
  • 做公司产品展示网站西安百度推广代运营
  • 什么网站做ppt好seo岗位是什么意思
  • 怎么做外围网站代理东莞优化网站关键词优化
  • 为什么网站很少做全屏百度收录查询网址
  • 乾县网站建设太原百度快照优化排名
  • 个人网站怎么做微信支付西安百度推广网站建设
  • 购物网站建设平台网络营销策划推广公司
  • 淘宝内部优惠券网站建设深圳 网站制作
  • 南昌做网站要多少钱近两年网络营销成功案例
  • 产品设计专业最好的大学seo优化效果怎么样
  • 网站关键词怎么修改做百度推广
  • 搭建一个电商网站需要多少费用中国刚刚发生8件大事
  • 广州公司网站建设公司网络营销推广技巧
  • 九江做网站的大公司沧州搜索引擎优化
  • 网站怎么做才沈阳关键词优化费用
  • 莆田网站格在哪里做引流推广平台有哪些
  • 河源做网站的客户最新新闻消息
  • 做爰全过程免费网站可以看郑州搜索引擎优化
  • 安徽智能网站建设哪里有磁力狗最佳搜索引擎
  • 免费创建单页网站高端网站建设定制
  • 网站上传空间seo如何提升排名收录
  • 深圳做网站做app百度的seo关键词优化怎么弄
  • 做图片网站会侵权吗市场营销的八个理论
  • 网站建设怎么建好网站建设开发公司
  • 商业网站的后缀利用搜索引擎营销成功的案例
  • 网络营销师资格证报名整站外包优化公司
  • 做医药商城网站的公司吗百度公司官网
  • 西安商城网站建设咪豆百度小说排行榜完本