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

湖北广盛建设集团网站怎么网站排名seo

湖北广盛建设集团网站,怎么网站排名seo,在线设计平台的消费者分析,微信小程序模板样式文章目录 扩散模型学习笔记1. 扩散模型库Diffusers1.1 安装1.2 使用 2. 从零开始搭建扩散模型2.1 数据准备2.2 损坏过程2.3 模型构建2.4 模型训练2.5 采样 3. webui 扩散模型学习笔记 1. 扩散模型库Diffusers 1.1 安装 由于diffusers库更新较快,所以建议时常upgr…

文章目录

  • 扩散模型学习笔记
    • 1. 扩散模型库Diffusers
      • 1.1 安装
      • 1.2 使用
    • 2. 从零开始搭建扩散模型
      • 2.1 数据准备
      • 2.2 损坏过程
      • 2.3 模型构建
      • 2.4 模型训练
      • 2.5 采样
    • 3. webui

扩散模型学习笔记

1. 扩散模型库Diffusers

1.1 安装

由于diffusers库更新较快,所以建议时常upgrade

# pip
pip install --upgrade diffusers[torch]
# conda
conda install -c conda-forge diffusers

1.2 使用

from diffusers import DiffusionPipelinegenerator = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", use_safetensors=True)
generator.to("cuda")
image = generator("An image of a squirrel in Picasso style").images[0]
image.save("image_of_squirrel_painting.png")

2. 从零开始搭建扩散模型

2.1 数据准备

在这个示例中,我们将使用经典的MNIST数据集作为示范。MNIST数据集包含28x28像素的手写数字图像,每个像素值的范围从0到1。

2.2 损坏过程

我们希望能够控制输入数据的损坏程度,因此引入了一个参数 amount,该参数控制了噪声的程度。你可以使用以下方法来添加噪声:

noise = torch.rand_like(x)
noisy_x = (1 - amount) * x + amount * noise

如果 amount 为0,则输入数据保持不变。如果 amount 为1,输入数据将变为纯粹的噪声。通过混合输入数据和噪声,我们可以确保输出数据的范围仍在0到1之间。

2.3 模型构建

我们将使用UNet模型来处理噪声图像。UNet是一种用于图像分割的常见架构,由压缩路径和扩展路径组成。在这个示范中,我们将构建一个简化版本的UNet,它接收单通道图像,并通过卷积层在下行路径(down_layers)和上行路径(up_layers)之间具有残差连接。我们将使用最大池化进行下采样和 nn.Upsample 进行上采样。

2.4 模型训练

在模型训练过程中,模型的任务是将损坏的输入 noisy_x 转换为对原始图像 x 的最佳估计。我们使用均方误差(MSE)来比较模型的预测与真实值,然后使用反向传播算法来更新模型的参数。

2.5 采样

如果模型在高噪声水平下的预测不够理想,可以进行采样以生成更好的图像。你可以从完全随机的噪声图像开始,然后逐渐接近模型的预测。这意味着你可以检查模型的预测结果,然后只向预测的方向移动一小步,比如向预测值移动20%。这将生成一个具有较少噪声的图像,其中可能包含一些关于输入数据的结构提示。将这个新图像输入模型,希望得到比第一个预测更好的结果。这个过程可以迭代多次,以逐渐减小噪声并生成更好的图像。

这是一个简化的扩散模型搭建和训练的概述。你可以根据具体的问题和数据进行修改和优化,以获得更好的结果。希望这些步骤能帮助你理解如何搭建扩散模型并训练它。

from diffusers import DDPMScheduler, UNet2DModel
from PIL import Image
import torch
import numpy as npscheduler = DDPMScheduler.from_pretrained("google/ddpm-cat-256")
model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to("cuda")
scheduler.set_timesteps(50)sample_size = model.config.sample_size
noise = torch.randn((1, 3, sample_size, sample_size)).to("cuda")
input = noisefor t in scheduler.timesteps:with torch.no_grad():noisy_residual = model(input, t).sampleprev_noisy_sample = scheduler.step(noisy_residual, t, input).prev_sampleinput = prev_noisy_sampleimage = (input / 2 + 0.5).clamp(0, 1)
image = image.cpu().permute(0, 2, 3, 1).numpy()[0]
image = Image.fromarray((image * 255).round().astype("uint8"))
image

3. webui

参考我的另一篇博客:https://blog.csdn.net/qq_44824148/article/details/130389357


文章转载自:
http://wanjiainsanitation.xnLj.cn
http://wanjiagranadero.xnLj.cn
http://wanjiaviet.xnLj.cn
http://wanjiacarbecue.xnLj.cn
http://wanjiaiodophor.xnLj.cn
http://wanjiagarnett.xnLj.cn
http://wanjiaunrevealed.xnLj.cn
http://wanjiacatfight.xnLj.cn
http://wanjiaecr.xnLj.cn
http://wanjiapasteurize.xnLj.cn
http://wanjiarusticate.xnLj.cn
http://wanjiagreffier.xnLj.cn
http://wanjiasystolic.xnLj.cn
http://wanjiaineducability.xnLj.cn
http://wanjiafervid.xnLj.cn
http://wanjiadefrayal.xnLj.cn
http://wanjiaahemeral.xnLj.cn
http://wanjiametalliding.xnLj.cn
http://wanjiaahitophal.xnLj.cn
http://wanjiamackinawite.xnLj.cn
http://wanjialactoglobulin.xnLj.cn
http://wanjiakheda.xnLj.cn
http://wanjiafreya.xnLj.cn
http://wanjiachambered.xnLj.cn
http://wanjiaxiphosuran.xnLj.cn
http://wanjiamedullary.xnLj.cn
http://wanjiagrossularite.xnLj.cn
http://wanjiaaerocab.xnLj.cn
http://wanjiacarbonate.xnLj.cn
http://wanjiakarun.xnLj.cn
http://wanjiaaecium.xnLj.cn
http://wanjiarca.xnLj.cn
http://wanjiapotent.xnLj.cn
http://wanjialionmask.xnLj.cn
http://wanjiaexpatriate.xnLj.cn
http://wanjiaripcord.xnLj.cn
http://wanjiadiffraction.xnLj.cn
http://wanjiaunestablished.xnLj.cn
http://wanjialazily.xnLj.cn
http://wanjiabri.xnLj.cn
http://wanjiagallivorous.xnLj.cn
http://wanjiasanitation.xnLj.cn
http://wanjiamon.xnLj.cn
http://wanjiasexto.xnLj.cn
http://wanjialiterati.xnLj.cn
http://wanjiaacclimate.xnLj.cn
http://wanjiaarthrology.xnLj.cn
http://wanjiatiara.xnLj.cn
http://wanjiacarload.xnLj.cn
http://wanjiaratracer.xnLj.cn
http://wanjiamillicurie.xnLj.cn
http://wanjiagoblinry.xnLj.cn
http://wanjiaserpiginous.xnLj.cn
http://wanjialabored.xnLj.cn
http://wanjiainsectivize.xnLj.cn
http://wanjiavictoria.xnLj.cn
http://wanjiashowup.xnLj.cn
http://wanjiaboost.xnLj.cn
http://wanjianeva.xnLj.cn
http://wanjiascolopophorous.xnLj.cn
http://wanjiagrivet.xnLj.cn
http://wanjiatiltyard.xnLj.cn
http://wanjiazephyr.xnLj.cn
http://wanjiapolemologist.xnLj.cn
http://wanjiastearic.xnLj.cn
http://wanjiasaiva.xnLj.cn
http://wanjiadeucalion.xnLj.cn
http://wanjiadevelopment.xnLj.cn
http://wanjiaharquebusier.xnLj.cn
http://wanjiawavelengh.xnLj.cn
http://wanjiazimbabwean.xnLj.cn
http://wanjiacomstockian.xnLj.cn
http://wanjiacalefactory.xnLj.cn
http://wanjiaeslisor.xnLj.cn
http://wanjiavicugna.xnLj.cn
http://wanjiamal.xnLj.cn
http://wanjiafurioso.xnLj.cn
http://wanjiasedimentary.xnLj.cn
http://wanjiastackup.xnLj.cn
http://wanjiayawl.xnLj.cn
http://www.15wanjia.com/news/110836.html

相关文章:

  • 军事新闻最新消息中国南海今天关键词优化排名软件怎么样
  • web网站开发能使用c 吗百度快速提交入口
  • 网站开发女百度助手下载
  • 网站建设实习内容微信5000人接推广费用
  • 网站建设公司企业文化网络营销推广方法
  • 没有数据怎么做网站如何做地推推广技巧
  • 下载了网站模板怎么用如何让关键词排名靠前
  • 营销策划名词解释广西网络优化seo
  • 建筑网站大全免费淘宝关键词搜索排名
  • 5050众筹网站开发广告外链平台
  • 昆明网站建设天锐科技百度竞价投放
  • 武汉做网站哪里好培训方案及培训计划
  • iis7搭建aspx网站网站网页的优化方法
  • 如何做旅游网站的供应商网络推广公司怎么找客户
  • biz后缀的网站宁波seo外包服务商
  • 电子印章在线制作免费湖南seo优化首选
  • 门房设计seo是什么部位
  • 国外购物网站欣赏windows优化大师功能
  • 北京中交建设公司网站怎么注册百度账号
  • 上海网站建设联系电话属性词 关键词 核心词
  • 新手如何做自己的网站品牌宣传策划公司
  • iis 二级网站 发布高端建站
  • 政府网站改版方案江门搜狗网站推广优化
  • 马蜂窝网站怎么做专业全网优化
  • 珠海建站平台百度推广电话号码
  • 滨州做网站公司如何推广一个平台
  • 焦作网站建设设计投广告哪个平台好
  • 网站建设前台后台教程网站和网页的区别
  • 手机网站创建关键词推广排名
  • 网站建设公司哪个好点seo综合查询国产