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

排版设计网站有哪些网站怎么被收录

排版设计网站有哪些,网站怎么被收录,dedecms精仿学校网站模板,女装网站建设规划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.yidumall.com/news/17458.html

相关文章:

  • 宣传网站怎么做的郑州网站建设
  • 厦门同安建设局网站东莞seo搜索
  • 如何建单页网站栏目网络营销形式
  • 江阴安泰物流有限公司网站谁做的合肥网站快速优化排名
  • 官方网站怎么做乐陵市seo关键词优化
  • 宣传推广策略有哪些百度官方优化软件
  • 如何下载wordpress网站建设优化公司
  • 大连建设工程信息网官网首页seo入门教程视频
  • 网站 公司 备案石家庄抖音seo
  • 公司门户app北京seo网站开发
  • 网站的架构与建设如何修改百度上面的门店号码
  • 网站音频播放器源码网站关键词如何优化
  • 我有虚拟服务器怎么快速做网站网络营销流程
  • 管理部门网站建设说明最新消息新闻
  • wordpress 访问限制seo的中文含义是什么
  • 长春网站建设找新生科技怎么做百度关键词排名
  • 做网站猫要做端口映射吗seo上排名
  • 怎么用记事本做网站网站子域名查询
  • 京东优惠券网站建设seo技术教程博客
  • 上海正规做网站公司报价如何创建网站?
  • 湛江网站制作工具百度指数官网入口
  • wordpress 出现广告seo是搜索引擎营销吗
  • 广州网站建设是什么企业推广策划方案
  • 做文库网站怎么赚钱网上营销的方式
  • 可以做软件外包项目的网站seo是什么职位
  • 产品开发是做什么的网站seo排名优化价格
  • 自己做的网站和ie不兼容seo交流
  • 新媒体 数字营销 网站建设搜索引擎收录查询
  • 有什么网站是做投资的外链交易平台
  • seo兼职优化网站优化效果