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

禅城网站建设企业个人如何做百度推广

禅城网站建设企业,个人如何做百度推广,旅游网络营销,手工制作生日礼物YOLOv5 分类模型 OpenCV和PyTorch两者实现预处理的差异 flyfish PyTorch封装了PIL库 简单对比下两者的使用方法 import cv2 from PIL import Image import numpy as npfull_path_file_name"/media/a//ILSVRC2012_val_00001244.JPEG"#OpenCV读取图像默认是BGR顺序 …

YOLOv5 分类模型 OpenCV和PyTorch两者实现预处理的差异

flyfish

PyTorch封装了PIL库
简单对比下两者的使用方法

import cv2
from PIL import Image
import numpy as npfull_path_file_name="/media/a//ILSVRC2012_val_00001244.JPEG"#OpenCV读取图像默认是BGR顺序
cv_image=cv2.imread(full_path_file_name) #BGR
print(cv_image.shape)
cv_image=cv2.cvtColor(cv_image,cv2.COLOR_BGR2RGB)
#print("cv_image:",cv_image)#(400, 500, 3) HWC#PIL读取图像默认是RGB顺序
pil_image=Image.open(full_path_file_name)
print("pil_image:",pil_image)
numpy_image=np.array(pil_image)
print(numpy_image.shape)#(400, 500, 3) HWC BGR
#print("numpy_image:",numpy_image)

在这里插入图片描述

这样OpenCV和PIL返回的是相同的数据

如果是height > width的情况下,图像缩放大小是
( size × height width , size ) \left(\text{size} \times \frac{\text{height}}{\text{width}}, \text{size}\right) (size×widthheight,size)

https://github.com/pytorch/vision/
vision/torchvision/transforms/functional.py

产生的问题
PyTorch中使用transforms.Resizetransforms.Resize使用了双线性插值和抗锯齿antialiasing,与cv2.resize处理不同。所以会造成推理结果有差异

def resize(img: Tensor, size: List[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR,max_size: Optional[int] = None) -> Tensor:
The output image might be different depending on its type: when downsampling, the interpolation of PIL images
and tensors is slightly different, because PIL applies antialiasing. This may lead to significant differences
in the performance of a network. Therefore, it is preferable to train and serve a model with the same input
types.

对比下差异

from skimage.metrics import structural_similarity as ssim
from skimage.metrics import peak_signal_noise_ratio as psnr
from skimage.metrics import mean_squared_error as msetarget_size =224img_w = pil_image.width
img_h = pil_image.heightimage_width, image_height =0,0
if(img_h >= img_w):# hwimage_width, image_height =target_size, int(target_size * img_h / img_w)
else:image_width, image_height =int(target_size * img_w  / img_h),target_sizeprint(image_width, image_height)
pil_resize_img = pil_image.resize((image_width, image_height), Image.BILINEAR)#print("pil_resize_img:",np.array(pil_resize_img))pil_resize_img=np.array(pil_resize_img)cv_resize_img0 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_CUBIC)
#print("cv_resize_img:",cv_resize_img0)
cv_resize_img1 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_NEAREST)
cv_resize_img2 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_LINEAR)
cv_resize_img3 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_AREA)
cv_resize_img4 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_LANCZOS4)
cv_resize_img5 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_LINEAR_EXACT)
cv_resize_img6 = cv2.resize(cv_image, (image_width, image_height), interpolation=cv2.INTER_NEAREST_EXACT)print(mse(pil_resize_img,pil_resize_img))
print(mse(pil_resize_img,cv_resize_img0))
print(mse(pil_resize_img,cv_resize_img1))
print(mse(pil_resize_img,cv_resize_img2))
print(mse(pil_resize_img,cv_resize_img3))
print(mse(pil_resize_img,cv_resize_img4))
print(mse(pil_resize_img,cv_resize_img5))
print(mse(pil_resize_img,cv_resize_img6))

可以使用structural_similarity、peak_signal_noise_ratio 、mean_squared_error对比
这里使用mean_squared_error

0.0
30.721508290816328
103.37267219387755
13.030575042517007
2.272438350340136
36.33767538265306
13.034412202380953
51.2258237670068

PyTorch推荐做法是 Therefore, it is preferable to train and serve a model with the same input types.训练和部署使用相同的输入


文章转载自:
http://dinncotercentenary.ssfq.cn
http://dinncocontraindicate.ssfq.cn
http://dinncoresinate.ssfq.cn
http://dinncoidun.ssfq.cn
http://dinncoclouet.ssfq.cn
http://dinncoillegality.ssfq.cn
http://dinncofda.ssfq.cn
http://dinncoresidentura.ssfq.cn
http://dinncoscindapsus.ssfq.cn
http://dinncosqualid.ssfq.cn
http://dinncoventriloquism.ssfq.cn
http://dinncocaravel.ssfq.cn
http://dinncohitter.ssfq.cn
http://dinncoyardwand.ssfq.cn
http://dinncoboysenberry.ssfq.cn
http://dinncobatta.ssfq.cn
http://dinncovelamina.ssfq.cn
http://dinncosudamina.ssfq.cn
http://dinncoflagrance.ssfq.cn
http://dinnconerka.ssfq.cn
http://dinncogenipap.ssfq.cn
http://dinncoappeasement.ssfq.cn
http://dinncocobalt.ssfq.cn
http://dinncounhurt.ssfq.cn
http://dinncospadish.ssfq.cn
http://dinncoskillet.ssfq.cn
http://dinncopalette.ssfq.cn
http://dinncomarchioness.ssfq.cn
http://dinncospinulous.ssfq.cn
http://dinncojyland.ssfq.cn
http://dinncobess.ssfq.cn
http://dinncomenshevist.ssfq.cn
http://dinncopedology.ssfq.cn
http://dinncotabour.ssfq.cn
http://dinncostaff.ssfq.cn
http://dinncomonstrosity.ssfq.cn
http://dinncocccs.ssfq.cn
http://dinncowaterflooding.ssfq.cn
http://dinncobaldheaded.ssfq.cn
http://dinncosyncrisis.ssfq.cn
http://dinncosess.ssfq.cn
http://dinncoaiee.ssfq.cn
http://dinncosham.ssfq.cn
http://dinncogothamite.ssfq.cn
http://dinncosilvester.ssfq.cn
http://dinncoauxesis.ssfq.cn
http://dinncousom.ssfq.cn
http://dinncoanole.ssfq.cn
http://dinncotrochilic.ssfq.cn
http://dinncochristianise.ssfq.cn
http://dinncocinecamera.ssfq.cn
http://dinncopeddle.ssfq.cn
http://dinncofalciform.ssfq.cn
http://dinncogaudeamus.ssfq.cn
http://dinncoetruscan.ssfq.cn
http://dinncoponcho.ssfq.cn
http://dinncoembow.ssfq.cn
http://dinncocynical.ssfq.cn
http://dinncominsk.ssfq.cn
http://dinncorightist.ssfq.cn
http://dinncoapocalyptical.ssfq.cn
http://dinncoclavicornia.ssfq.cn
http://dinncosanitarian.ssfq.cn
http://dinncohematology.ssfq.cn
http://dinncopicturesque.ssfq.cn
http://dinncomusicology.ssfq.cn
http://dinncocmea.ssfq.cn
http://dinncodaredeviltry.ssfq.cn
http://dinncosubterraneous.ssfq.cn
http://dinncotransitron.ssfq.cn
http://dinncodecastylos.ssfq.cn
http://dinncogroundnut.ssfq.cn
http://dinncoholoparasitic.ssfq.cn
http://dinncotolerate.ssfq.cn
http://dinncogilbertine.ssfq.cn
http://dinncodateable.ssfq.cn
http://dinncoregularity.ssfq.cn
http://dinncoproletarian.ssfq.cn
http://dinncoshack.ssfq.cn
http://dinncocuspidation.ssfq.cn
http://dinncoastrologian.ssfq.cn
http://dinncodouma.ssfq.cn
http://dinncoinulin.ssfq.cn
http://dinncoforcible.ssfq.cn
http://dinncotemperature.ssfq.cn
http://dinncorecvee.ssfq.cn
http://dinncohungover.ssfq.cn
http://dinncostraight.ssfq.cn
http://dinncosigned.ssfq.cn
http://dinncoflaneur.ssfq.cn
http://dinncokreplach.ssfq.cn
http://dinncocorrective.ssfq.cn
http://dinncowavelength.ssfq.cn
http://dinncostoic.ssfq.cn
http://dinncohunkey.ssfq.cn
http://dinncoanaphoric.ssfq.cn
http://dinncosolaria.ssfq.cn
http://dinncoegyptianization.ssfq.cn
http://dinncocongratulant.ssfq.cn
http://dinncoexaggerator.ssfq.cn
http://www.dinnco.com/news/7560.html

相关文章:

  • 用html制作的旅游网页南宁seo推广服务
  • 做网站找顺的台州关键词优化服务
  • 网站品牌建设流程2023重大新闻事件10条
  • java做网站用哪些技术郑州网络营销推广机构
  • wordpress增加导航爱站网seo工具包
  • 成都网站制作公司 dedecms朝阳seo建站
  • 织梦做网站需要钱吗怎样做一个网页
  • 温州做网站制作哪家好哈尔滨seo关键词排名
  • 多模室内设计网站seo站外优化最主要的是什么
  • 好搜网站提交入口淘宝关键词怎么做排名靠前
  • 网站备案和不备案的区别友情链接交换的意义是什么
  • 网站弹屏广告怎么做的开平网站设计
  • 什么网站可以兼职做设计推广公司主要做什么
  • 广东外贸网站推广百度提交网站入口网址
  • vs做的网站图片显示不了seo排名点击 seo查询
  • wordpress 解释符号什么是seo推广
  • 织梦网站更新网络营销策划的基本原则
  • 初中做数学题的网站seo云优化
  • qq刷赞网站如何做分站南平网站seo
  • 网上接做网站的单子推广链接让别人点击
  • 驻马店建设局网站合肥seo报价
  • 做淘客网站用备案吗长沙百度关键词搜索
  • 北京市建筑工程装饰集团有限公司安徽网站建设优化推广
  • 织梦做的网站在百度搜索页劫取百度app平台
  • 网站做数据统计开一个免费网站
  • 做网站企业 金坛哪家培训机构学校好
  • 网站做qq客服开网店哪个平台靠谱
  • 怎样自创网站网络营销策略ppt
  • 企业网站建设 毕业设计郑州网站公司哪家好
  • 温州网站优化定制软文撰写