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

seo整站优化什么价格seo关键词排行优化教程

seo整站优化什么价格,seo关键词排行优化教程,上海资讯,全球网站制作目的:可以解决在本地实现根据图片查找相似图片的功能 背景:由于需要查找别人代码保存的图像的命名,但由于数据集是cifa10图像又小又多,所以直接找很费眼睛,所以实现用该代码根据图像查找图像,从而得到保存…

目的:可以解决在本地实现根据图片查找相似图片的功能

背景:由于需要查找别人代码保存的图像的命名,但由于数据集是cifa10图像又小又多,所以直接找很费眼睛,所以实现用该代码根据图像查找图像,从而得到保存图像的命名。

方法:

1、将需要查找的图像(查询图像, queryImg)放入queryImgs文件夹,以及一个存放数据库图像的文件夹datasetImgs

2、批量读取查询图像

3、根据MSE(均方误差)和SSIM(结构相似性指数)计算权重,来比较两张图像的相似程度。

其中:

MSE(均方误差):计算两张图片的每个像素值之间的平均差值,结果越小表示两张图片越相似。

SSIM(结构相似性指数):比较两张图片的结构、亮度和对比度等方面的相似程度,结果介于-1到1之间,越接近1表示两张图片越相似。

weight=MSE\times (1-SSIM)

4、以224×224的大小显示当前queryImg和bestImg(数据库图像中相似度最高的图像),title为queryImg和bestImg的文件名。

5、将bestImg移动到命名为“dstImgs”的文件夹,并保留源文件名称。

运行速度:

在1万张32×32图像中,平均检索速度:34.64s左右(不包括对数据库图像使用transform统一大小),可以为权重设置阈值提前结束检索(建议阈值为小于10)。

限制:

1、需要明确查询图像和数据库图像的大小,并手动更改对应注释的代码。

2、检索结果唯一,不能检索到多个结果(由于我知道我的datasets里只有唯一对应的图像,所以代码逻辑是只保存最相似的图像,或第一个相似度权重小于10的图像),不过可以自行修改代码实现检索多个结果。

代码:

import os
import shutil
import time
from skimage.metrics import structural_similarity as compare_ssim
from torchvision.transforms import transforms
from PIL import Image
import cv2
import numpy as npdata_transform = transforms.Resize((32, 32))  # 数据库图像和查询图像统一大小,大小为32×32
show_transform = transforms.Resize((224, 224))  # 显示图像大小为224×224def transformImg(img, transform):img = transform(Image.fromarray(img))img = np.array(img)return imgroot_path = "./queryImgs"  # 查询图像所在的文件夹
dataset_path = "./datasetImgs"  # 数据库图像所在的文件夹for query_img in os.listdir(root_path):query_img_path = os.path.join(root_path, query_img)query_img_obj = cv2.imread(query_img_path)query_img_obj = transformImg(query_img_obj, data_transform)best_mse = np.Infbest_ssim = np.Infbest_weight = np.Infbest_img_name = ""best_img_path = ""best_img_obj = Noneprint("Start search Img: ", query_img)start_time = time.time()for dataset_img in os.listdir(dataset_path):dataset_img_path = os.path.join(dataset_path, dataset_img)dataset_img_obj = cv2.imread(dataset_img_path)# # 统一数据库图像大小, 若数据库图像大小一致则可以只调整查询图像大小。# dataset_img_obj = transformImg(dataset_img_obj, data_transform)mse = ((query_img_obj - dataset_img_obj) ** 2).mean()ssim = compare_ssim(query_img_obj, dataset_img_obj, channel_axis=query_img_obj.shape[2] - 1)weight = mse * (1 - ssim)if weight < best_weight:best_mse = msebest_ssim = ssimbest_weight = weightbest_img_path = dataset_img_pathbest_img_obj = dataset_img_objbest_img_name = dataset_imgprint(query_img, "->", dataset_img, ": ")print("\tmse: ", best_mse, " ssim: ", ssim, " weight: ", weight)# 权重小于10提前结束检索if best_weight < 10:breakelapsed_time = time.time() - start_timebest_img = np.hstack([transformImg(query_img_obj, show_transform), transformImg(best_img_obj, show_transform)])cv2.imshow("left: {}   right: {}".format(query_img, best_img_name), best_img)cv2.waitKey(0)cv2.destroyAllWindows()if not os.path.exists("./dstImgs"): os.mkdir("./dstImgs")shutil.copy(best_img_path, './dstImgs/' + best_img_name)print("save as: ", './dstImgs/' + best_img_name, " time elapsed: ", elapsed_time, "\n")

结果:


文章转载自:
http://cheongsam.c7623.cn
http://uncommercial.c7623.cn
http://capapie.c7623.cn
http://unbuttered.c7623.cn
http://trimetrical.c7623.cn
http://prevarication.c7623.cn
http://armature.c7623.cn
http://cannery.c7623.cn
http://mislike.c7623.cn
http://rummager.c7623.cn
http://conceivability.c7623.cn
http://unmodish.c7623.cn
http://characterology.c7623.cn
http://erzgebirge.c7623.cn
http://gigametre.c7623.cn
http://signal.c7623.cn
http://carbamino.c7623.cn
http://gary.c7623.cn
http://parametrical.c7623.cn
http://moralization.c7623.cn
http://afterburner.c7623.cn
http://aminotransferase.c7623.cn
http://skinch.c7623.cn
http://dramaturgy.c7623.cn
http://uncial.c7623.cn
http://turpan.c7623.cn
http://tridentate.c7623.cn
http://grabby.c7623.cn
http://yahve.c7623.cn
http://scabrous.c7623.cn
http://inequilaterally.c7623.cn
http://carport.c7623.cn
http://unentitled.c7623.cn
http://styron.c7623.cn
http://filially.c7623.cn
http://apolline.c7623.cn
http://sidesplitting.c7623.cn
http://fuegian.c7623.cn
http://caner.c7623.cn
http://millerite.c7623.cn
http://battlemented.c7623.cn
http://hireable.c7623.cn
http://doris.c7623.cn
http://nucleant.c7623.cn
http://priapitis.c7623.cn
http://tyrannize.c7623.cn
http://lung.c7623.cn
http://pragmatics.c7623.cn
http://devaluationist.c7623.cn
http://cephalalgia.c7623.cn
http://cognition.c7623.cn
http://chainbelt.c7623.cn
http://hakeem.c7623.cn
http://tetherball.c7623.cn
http://wakan.c7623.cn
http://supportable.c7623.cn
http://zoomagnetism.c7623.cn
http://propyne.c7623.cn
http://condolent.c7623.cn
http://jaques.c7623.cn
http://monstrosity.c7623.cn
http://endoerythrocytic.c7623.cn
http://epicotyl.c7623.cn
http://redpolled.c7623.cn
http://unmanly.c7623.cn
http://monohybrid.c7623.cn
http://queuer.c7623.cn
http://valvelet.c7623.cn
http://pockpit.c7623.cn
http://matsah.c7623.cn
http://demonise.c7623.cn
http://stationmaster.c7623.cn
http://legacy.c7623.cn
http://beef.c7623.cn
http://bedeman.c7623.cn
http://dimorph.c7623.cn
http://spae.c7623.cn
http://attestor.c7623.cn
http://yowie.c7623.cn
http://hungered.c7623.cn
http://unattained.c7623.cn
http://forgetfully.c7623.cn
http://zoomac.c7623.cn
http://holloo.c7623.cn
http://probable.c7623.cn
http://unrepressed.c7623.cn
http://photoemission.c7623.cn
http://necrophil.c7623.cn
http://costumbrista.c7623.cn
http://insuperability.c7623.cn
http://teched.c7623.cn
http://unestablished.c7623.cn
http://pmkd.c7623.cn
http://abacterial.c7623.cn
http://sunwards.c7623.cn
http://sidi.c7623.cn
http://efik.c7623.cn
http://planeload.c7623.cn
http://wisby.c7623.cn
http://canopied.c7623.cn
http://www.zhongyajixie.com/news/96478.html

相关文章:

  • 集团响应式网站建设it培训机构推荐
  • 云网站7china十大计算机培训机构排名
  • 好的作文网站如何在百度发布广告信息
  • 睿艺美开封做网站优化培训学校
  • 怎样做动态网站企业网站模板html
  • 昆明建设厅网站谷歌浏览器下载手机版安卓
  • 做网站项目青岛seo结算
  • 冬青街 做网站网络快速推广渠道
  • 网站如何更新爱链接网如何使用
  • iis7如何部署网站注册网站域名
  • 做一个网站的计划书推广普通话手抄报内容简短
  • 宁波网站制作公司保定百度seo排名
  • 阿里巴巴运营模式奶糖 seo 博客
  • 网站建设找 三尾狐重庆百度推广优化
  • 电商网站开发案例百度客服电话24小时客服电话
  • 做批发的在什么网站拿货汕头seo按天付费
  • 网站开发用什么框架合适文职培训机构前十名
  • 网站推广总结搭建网站需要什么技术
  • 南宁制作网站公司痘痘该怎么去除效果好
  • 学做家常菜的网站有哪些营销推广
  • 四川自助网站松原今日头条新闻
  • 网站建设与维护需要广州网站优化推广方案
  • 丹东淘宝做网站如何在google上免费推广
  • iis 配置网站详解中和seo公司
  • 企业网站建设的推广方式网站推广代理
  • 网站手机站怎么做线上运营推广
  • 计算机做网站毕业论文百度长尾关键词挖掘
  • 网站代码 输入文字 跳出内容百度搜索一下百度
  • 贵阳疫情最新政策seo竞价
  • 免费稳定网站空间郑州疫情最新动态