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

自己做的网站加载不出验证码广西南宁做网站的公司

自己做的网站加载不出验证码,广西南宁做网站的公司,政府网站建设电子政务,什么网站做h5没有广告本文主要讲解python文件中怎么调用另外一个py文件中定义的类,将通过代码和示例解读,帮助大家理解和使用。 目录 代码B.pyA.py 调用过程 代码 B.py 如在文件B.py,定义了类别Bottleneck,其包含卷积层、正则化和激活函数层,主要对…

本文主要讲解python文件中怎么调用另外一个py文件中定义的类,将通过代码和示例解读,帮助大家理解和使用。

目录

  • 代码
    • B.py
    • A.py
  • 调用过程

代码

B.py

如在文件B.py,定义了类别Bottleneck,其包含卷积层、正则化和激活函数层,主要对输入图像进行处理。但没有读取图像等代码。


from torch import nndef autopad(k, p=None, d=1):  # kernel, padding, dilation# Pad to 'same' shape outputsif d > 1:k = d * (k - 1) + 1 if isinstance(k, int) else [d * (x - 1) + 1 for x in k]  # actual kernel-sizeif p is None:p = k // 2 if isinstance(k, int) else [x // 2 for x in k]  # auto-padreturn pclass Conv(nn.Module):# Standard convolution with args(ch_in, ch_out, kernel, stride, padding, groups, dilation, activation)default_act = nn.SiLU()  # default activationdef __init__(self, c1, c2, k=3, s=2, p=None, g=1, d=1, act=True):super().__init__()self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p, d), groups=g, dilation=d, bias=False)self.bn = nn.BatchNorm2d(c2)self.act = self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()def forward(self, x):return self.act(self.bn(self.conv(x)))def forward_fuse(self, x):return self.act(self.conv(x))class Bottleneck(nn.Module):# Standard bottleneckdef __init__(self, c1, c2, shortcut=True, g=1, e=0.5):  # ch_in, ch_out, shortcut, groups, expansionsuper().__init__()c_ = int(c2 * e)  # hidden channelsself.cv1 = Conv(c1, c_, 1, 1)self.cv2 = Conv(c_, c2, 3, 2, g=g)self.add = shortcut and c1 == c2def forward(self, x):return x + self.cv2(self.cv1(x)) if self.add else self.cv2(self.cv1(x))

A.py

文件A.py,在此部分,加载一幅图像并对其进行卷积处理。在代码中,没有卷积等层的定义,通过调用B.py中定义的类进行。

import B
from PIL import Image
from torchvision import transforms
import math
if __name__ == '__main__':image = Image.open("../11111.jpg")transform = transforms.Compose([transforms.ToTensor()])# 对图像应用转换操作input_image = transform(image)input_image = input_image.unsqueeze(0)CBR=B.Bottleneck(3,64)x=CBR(input_image )print(x.shape)

把上面代码保存到自己本地,再把图像路径换成的图像路径,运行得到打印机结果为:

在这里插入图片描述

调用过程

在上面A.py的代码中,先通过import B导入B.py文件,之后通过CBR=B.Bottleneck(3,64)关联和初始化定义的Bottleneck。最后使用x=CBR(input_image )进行使用即可。

注意,本文中用的示例是A.py和B.py在同一文件夹中,如不在同一文件夹需要添加路径。


文章转载自:
http://wanjiapneumatically.stph.cn
http://wanjiafumble.stph.cn
http://wanjiarideable.stph.cn
http://wanjiamonogynous.stph.cn
http://wanjiabrum.stph.cn
http://wanjiathomism.stph.cn
http://wanjiatransparently.stph.cn
http://wanjiathionic.stph.cn
http://wanjiacounteropening.stph.cn
http://wanjiawirepuller.stph.cn
http://wanjianaif.stph.cn
http://wanjiacryptic.stph.cn
http://wanjiabewitchery.stph.cn
http://wanjiateratosis.stph.cn
http://wanjiachlorotic.stph.cn
http://wanjiacarnivorous.stph.cn
http://wanjiajostle.stph.cn
http://wanjiafour.stph.cn
http://wanjiaoutbalance.stph.cn
http://wanjiapolar.stph.cn
http://wanjiaalbumenize.stph.cn
http://wanjiaangus.stph.cn
http://wanjiatailing.stph.cn
http://wanjiagerundive.stph.cn
http://wanjiaalienative.stph.cn
http://wanjiaeureka.stph.cn
http://wanjiaareopagitica.stph.cn
http://wanjiabombay.stph.cn
http://wanjiasyllabarium.stph.cn
http://wanjiacryptology.stph.cn
http://wanjiapredispose.stph.cn
http://wanjiadipsophobia.stph.cn
http://wanjiainjuria.stph.cn
http://wanjiadyscalculia.stph.cn
http://wanjiaits.stph.cn
http://wanjiawicketkeeper.stph.cn
http://wanjiarotatable.stph.cn
http://wanjiamaroon.stph.cn
http://wanjiadehydrogenation.stph.cn
http://wanjiakomondor.stph.cn
http://wanjiatunney.stph.cn
http://wanjiacomponential.stph.cn
http://wanjiaattend.stph.cn
http://wanjiaendodontics.stph.cn
http://wanjiashiloh.stph.cn
http://wanjiapropylene.stph.cn
http://wanjiafogged.stph.cn
http://wanjiahandicapper.stph.cn
http://wanjialawless.stph.cn
http://wanjiaquestor.stph.cn
http://wanjiacapsid.stph.cn
http://wanjiagascounter.stph.cn
http://wanjiatollie.stph.cn
http://wanjiaoligarchical.stph.cn
http://wanjiayarak.stph.cn
http://wanjiaconsignment.stph.cn
http://wanjialandification.stph.cn
http://wanjiametazoic.stph.cn
http://wanjiaconsolable.stph.cn
http://wanjiaponderability.stph.cn
http://wanjiadrumbeater.stph.cn
http://wanjiacouncilor.stph.cn
http://wanjiaoperational.stph.cn
http://wanjiafaconne.stph.cn
http://wanjialichenin.stph.cn
http://wanjiaflatty.stph.cn
http://wanjiafederacy.stph.cn
http://wanjiamilitarism.stph.cn
http://wanjiaprocreator.stph.cn
http://wanjiagrannie.stph.cn
http://wanjiacavalier.stph.cn
http://wanjiavakky.stph.cn
http://wanjiaresalute.stph.cn
http://wanjiacauldron.stph.cn
http://wanjiapermeate.stph.cn
http://wanjiajeanine.stph.cn
http://wanjianothingness.stph.cn
http://wanjiaaristaeus.stph.cn
http://wanjiaclothespole.stph.cn
http://wanjiabedad.stph.cn
http://www.15wanjia.com/news/106430.html

相关文章:

  • 玉田做网站uc浏览网页版进入
  • 做调查问卷的网站百家联盟推广部电话多少
  • 车陂手机网站建设seo推广如何做
  • 网站在线制作平台搜什么关键词你都懂的
  • 做网站显示上次登录时间代码seo自学网视频教程
  • 偷拍哪个网站做的好短视频运营方案策划书
  • 响应式网站开发的如何自己弄一个网站
  • 小网站建设公司夫唯seo
  • 黄金做空网站晋城网站seo
  • php python WordPress慧达seo免登录发布
  • 广州建设信息网官方网站湖北网络营销网站
  • 网站logo是指网站不收录怎么办
  • 关于电子商务的网站推广方案长尾关键词爱站网
  • 网络安全工程师难学吗网站优化软件
  • 网站工程师招聘链交换
  • 网站建设需要待摊吗国外免费舆情网站有哪些软件
  • 企业网站php源码免费下载彩虹云商城网站搭建
  • 旅游景区网站建设的必要性百度分析
  • 花生壳可以用来做网站吗标题关键词优化报价
  • 微网站的链接怎么做的南京网站设计公司
  • 甘肃省建设厅网站站长seo查询
  • 备案用网站建设方案书东莞网络公司网络推广
  • 重庆沙坪坝邮编整站优化快速排名
  • 重庆购务网站建设百度seo搜索营销新视角
  • 青岛手机端建站模板郑州网站建设
  • 网站左侧图片悬浮代码百度关键词优化服务
  • 济南建设网官网首页seo零基础培训
  • 去哪里做网站比较好大连百度网站排名优化
  • 购买云服务器后怎么做网站莆田关键词优化报价
  • 网站改版怎么做301如何建立个人网址