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

中国网站设计模板wordpress中文版本

中国网站设计模板,wordpress中文版本,高端网站优化,网络营销概述1 关于Diffusers Pipeline 1.1 简介 大部分扩散模型包含多个独立训练的子模型和组件模块组合而成#xff0c;例如StableDiffusion 有#xff1a; 3个独立训练的子模型#xff1a;Autoencoder、 Conditional Unet、CLIP text encoder调度器组件scheduler,CLIPImageProcesso…1 关于Diffusers Pipeline 1.1 简介 大部分扩散模型包含多个独立训练的子模型和组件模块组合而成例如StableDiffusion 有 3个独立训练的子模型Autoencoder、 Conditional Unet、CLIP text encoder调度器组件scheduler,CLIPImageProcessor,safety checker. 为了让开发者以最简单的方式使用最新最先进的扩散模型diffusers开发了pipeline管理和使用这些类使得开发者可以以端对端方式使用扩散模型。 注意pipeline本身没有提供任何训练相关功能如果想要实现训练可以参考官方的训练样例 1.2 官方Pipeline 以下表格是diffusers官方实现的Pipeline每个Pipeline有对应的论文。 PipelineSourceTasksdance diffusionDance DiffusionUnconditional Audio GenerationddpmDenoising Diffusion Probabilistic ModelsUnconditional Image GenerationddimDenoising Diffusion Implicit ModelsUnconditional Image Generationlatent_diffusionHigh-Resolution Image Synthesis with Latent Diffusion ModelsText-to-Image Generationlatent_diffusion_uncondHigh-Resolution Image Synthesis with Latent Diffusion ModelsUnconditional Image GenerationpndmPseudo Numerical Methods for Diffusion Models on ManifoldsUnconditional Image Generationscore_sde_veScore-Based Generative Modeling through Stochastic Differential EquationsUnconditional Image Generationscore_sde_vpScore-Based Generative Modeling through Stochastic Differential EquationsUnconditional Image Generationstable_diffusionStable DiffusionText-to-Image Generationstable_diffusionStable DiffusionImage-to-Image Text-Guided Generationstable_diffusionStable DiffusionText-Guided Image Inpaintingstochastic_karras_veElucidating the Design Space of Diffusion-Based Generative ModelsUnconditional Image Generation 2 Pipeline API接口 扩散模型包含多个独立的模型和组件不同任务中模型独立训练并且可以用其他模型替换。不同的Pipeline可能包含专有的函数接口但所有Pipeline都有的共同函数如下 from_pretrained(cls, pretrained_model_name_or_path, **kwargs) 参数pretrained_model_name_or_path可以是 Hugging Face Hub repository的 id, 例如 runwayml/stable-diffusion-v1-5 或本地路径./stable-diffusion. 为了确保所有模型和组件能被正确加载需要提供一个 model_index.json 文件, 例如 runwayml/stable-diffusion-v1-5/model_index.json, 这个文件定义了所有要被加载的组件。其格式如下 name: [library, class name]其中name 是类class name实例的名称。此类可以在库library中加载到。save_pretrained(self, save_directory) : 参数save_directory为本地目录路径例如 ./stable-diffusion 所有的模型和组件会被保存。每个模型和组件创建一个对应的子目录子目录名称为模型或组件的属性名称如./stable_diffusion/unet. 此外还会再根目录创建 model_index.json 文件如./stable_diffusion/model_index.jsonto(self, torch_device: Optional[Union[str, torch.device]] None) 参数torch_device为 string 或 torch.device 类型将所有torch.nn.Module 类型的对象转移到指定的device上此函数与pytorch的to函数功能一致。__call__函数执行推理此函数定义了pipeline的推理逻辑不同的Pipeline对应的推理输入差别很大例如文生图Pipeline StableDiffusionPipeline 的输入应该是文本prompt输出是生成的图。 而DDPMPipeline 则无需提供任何输入。因此读者需要根据实际的Pipeline功能以及查看相应的官方文档使用。 注意: 所有的Pipeline的__call__函数会自动调用torch.no_grad函数禁用梯度因为Pipeline不是用于训练。如果你在前向推理后有保存梯度的需求可以自定义Pipeline参考官方示例 3 使用示例 1 扩散模型文生图 # make sure youre logged in with huggingface-cli login from diffusers import StableDiffusionPipeline, LMSDiscreteSchedulerpipe StableDiffusionPipeline.from_pretrained(runwayml/stable-diffusion-v1-5) pipe pipe.to(cuda)prompt a photo of an astronaut riding a horse on mars image pipe(prompt).images[0] image.save(astronaut_rides_horse.png)2 扩散模型图生图 类StableDiffusionImg2ImgPipeline 接受一个文本prompt和初始图片作为条件指导生成新图。 import requests from PIL import Image from io import BytesIOfrom diffusers import StableDiffusionImg2ImgPipeline# load the pipeline device cuda pipe StableDiffusionImg2ImgPipeline.from_pretrained(runwayml/stable-diffusion-v1-5,torch_dtypetorch.float16, ).to(device)# lets download an initial image url https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpgresponse 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 artstationimages pipe(promptprompt, imageinit_image, strength0.75, guidance_scale7.5).imagesimages[0].save(fantasy_landscape.png)可以在colab中直接运行colab 3 扩充模型In-painting 类 StableDiffusionInpaintPipeline 接受文本prompt和mask用于编辑图像指定区域。 import PIL import requests import torch from io import BytesIOfrom diffusers import StableDiffusionInpaintPipelinedef download_image(url):response requests.get(url)return PIL.Image.open(BytesIO(response.content)).convert(RGB)img_url https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png mask_url https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.pnginit_image download_image(img_url).resize((512, 512)) mask_image download_image(mask_url).resize((512, 512))pipe StableDiffusionInpaintPipeline.from_pretrained(runwayml/stable-diffusion-inpainting,torch_dtypetorch.float16, ) pipe pipe.to(cuda)prompt Face of a yellow cat, high resolution, sitting on a park bench image pipe(promptprompt, imageinit_image, mask_imagemask_image).images[0]可以在colab中直接运行 colab
http://www.hkea.cn/news/14479483/

相关文章:

  • 河南官网网站建设报价做ppt很有创意的网站
  • 可做长图的网站十堰今天刚刚发生新闻
  • 深圳网站公司推广平台张家港做网站的公司
  • 高明区住房和城乡建设局网站如何进行医药网站建设
  • 如何建设手机网站首页平面设计包括哪些软件
  • 易思腾网站建设环保部网站官网建设项目限批办法
  • 网站推广效益怎么分析免费网站在哪里申请
  • 上海建个人网站比较好的公司07073游戏网官网
  • 网站开发公司好开发客户吗视频上传网站如何做
  • 网站建设行业产业链分析长沙网约车驾驶员资格证网上报名
  • 房产网站定制做帮助手册的网站
  • 58网站 做现浇混凝土flash网站的优点和缺点
  • 网站开发为什么不用cgi了网络卖货怎么卖
  • 做一元购物网站互联网行业前景
  • 收录快网站公司网站做的比较好
  • 胶州企业网站建设玉环市建设规划局网站
  • 国外ps素材网站WordPress文章不让搜索
  • 模板网站哪家好做医疗护具网站
  • 长沙市规划建设局网站辽宁省兴城做网站的
  • 广州市网站建设企业网络营销4c策略是什么
  • 如何自己编写网站黑龙江省建设厅的网站首页
  • 网站建设 答辩记录多媒体应用设计师好考吗
  • js网站页面效果网站建设和编程的区别
  • 国内ui网站有哪些深圳公司免费网站建设怎么样
  • iis html网站怎么查看一个网站是谁做的
  • 网站模板带有sql后台下载泡沫制品技术支持东莞网站建设
  • 怎么看网站开发的技术做ctf的网站有哪些
  • 重庆网络建站wordpress设置文章期限
  • 网站运营设计发帖子最好的几个网站
  • 网站变成手机网站百度云搜索引擎入口官方