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

网页界面设计的功能性主要体现在信息的哪两个方面培训班线上优化

网页界面设计的功能性主要体现在信息的哪两个方面,培训班线上优化,wordpress小企业主题,设计派官网1. 普通模型 Optimum是huggingface transformers库的一个扩展包,用来提升模型在指定硬件上的训练和推理性能。Optimum支持多种硬件,不同硬件下的安卓方式如下: 如果是国内安装的话,记得加上-i https://pypi.tuna.tsinghua.edu.c…

1. 普通模型

Optimum是huggingface transformers库的一个扩展包,用来提升模型在指定硬件上的训练和推理性能。Optimum支持多种硬件,不同硬件下的安卓方式如下:
在这里插入图片描述
如果是国内安装的话,记得加上-i https://pypi.tuna.tsinghua.edu.cn/simple。
hugging face目前是被墙的状态,在使用示例代码时,需要将模型离线下载下来使用。
如下图,模型离线下载下来后的测试代码如下:
在这里插入图片描述
对比原模型,提速约一倍:
在这里插入图片描述

2. stable diffusion

首先安装diffusion库:pip install optimum[diffusers]
下载模型文件:

hugging face上是如下这个:
在这里插入图片描述
unet模型有3个多G,下载好后按照上面文件夹的格式放在程序的目录下。接下来是代码:

from optimum.intel import OVStableDiffusionPipeline
model_id = "echarlaix/stable-diffusion-v1-5-openvino"
pipeline = OVStableDiffusionPipeline.from_pretrained(model_id)
prompt = "sailing ship in storm by Rembrandt"
images = pipeline(prompt).images

如果我们是从pytorch模型export进来的,注意保存一下ov的模型:

model_id = "runwayml/stable-diffusion-v1-5"
pipeline = OVStableDiffusionPipeline.from_pretrained(model_id, export=True)
# Don't forget to save the exported model
pipeline.save_pretrained("openvino-sd-v1-5")

然后固定尺寸,加速推理:

# Define the shapes related to the inputs and desired outputs
batch_size = 1
num_images_per_prompt = 1
height = 512
width = 512# Statically reshape the model
pipeline.reshape(batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images_per_prompt)
# Compile the model before the first inference
pipeline.compile()# Run inference
images = pipeline(prompt, height=height, width=width, num_images_per_prompt=num_images_per_prompt).images

如果要添加Textual Inversion

pipeline.clear_requests()# Load textual inversion into stable diffusion pipeline
pipeline.load_textual_inversion("sd-concepts-library/cat-toy", "<cat-toy>")# Compile the model before the first inference
pipeline.compile()
image2 = pipeline(prompt, num_inference_steps=50).images[0]
image2.save("stable_diffusion_v1_5_with_textual_inversion.png")

如果是image-to-image:

import requests
import torch
from PIL import Image
from io import BytesIO
from optimum.intel import OVStableDiffusionImg2ImgPipelinemodel_id = "runwayml/stable-diffusion-v1-5"
pipeline = OVStableDiffusionImg2ImgPipeline.from_pretrained(model_id, export=True)url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((768, 512))
prompt = "A fantasy landscape, trending on artstation"
image = pipeline(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5).images[0]
image.save("fantasy_landscape.png")

结果如图:
在这里插入图片描述

http://www.mmbaike.com/news/68169.html

相关文章:

  • 网站开发需要的资料seo查询 工具
  • 网站备案授权书怎么填写北京网站优化合作
  • 网站开发人员薪酬seo技术培训泰州
  • 有没有免费的网站软件seo搜索引擎优化人才
  • 网站建设分配人员方案十大软件免费下载网站排行榜
  • 大型手机网站制作产品软文模板
  • 网站调研方法有哪些内容谷歌优化教程
  • 休闲食品网站建设策划书公司网站怎么申请怎么注册
  • 西安企业网站制作价格百度推广渠道户
  • 建设网站第一步内蒙古网站seo
  • 装修公司网站 源码郴州网站seo外包
  • 沈阳模板网站制作论述搜索引擎优化的具体措施
  • 网站建设的方法站长网站工具
  • 比较大气的网站专业提升关键词排名工具
  • 做货代的要注册哪种物流网站怎么找专业的营销团队
  • 视频网站的服务器建设怎么做推广
  • 哪里可以学习做网站想做游戏推广怎么找游戏公司
  • 东莞高埗做网站哪个公司好徐州网站建设方案优化
  • 三网合一网站建设方案市场营销试题库(带答案)
  • 推广网站建设产品介绍百度地图推广怎么做的
  • 优化型网站建设网络推广电话
  • 网上做家教的网站免费推广网站注册入口
  • asp.net建网站关键一招
  • 网站如何做推广开发一个app价目表
  • 全球疫情实时动态广州推广seo
  • 有哪几个网站可以做贸易查权重工具
  • 上海企业网站建设制作公司广告推广
  • 合肥专业网站优化价格手机网站建设价格
  • 成都网站改版优化百度广告关键词价格表
  • 做漂亮的网站百度旗下产品