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

培训教育网站开发建一个企业网站多少钱

培训教育网站开发,建一个企业网站多少钱,网站 点击量,怎么创建一个html网页文本的跑通了,接下来玩玩图片场景 1. 引入模型 再另起类test_qdrant_img.py,转化图片用到的模型和文本不太一样,我们这里使用ResNet-50模型 import unittest from qdrant_client.http.models import Distance, VectorParams from qdrant_cl…

文本的跑通了,接下来玩玩图片场景

1. 引入模型

再另起类test_qdrant_img.py,转化图片用到的模型和文本不太一样,我们这里使用ResNet-50模型

import unittest
from qdrant_client.http.models import Distance, VectorParams
from qdrant_client import QdrantClient
import torch
import torchvision.transforms as transforms
from PIL import Imageclass TestQDrantImg(unittest.TestCase):def setUp(self):self.collection_name = "img_collection"self.client = QdrantClient("localhost", port=6333)# 加载ResNet-50模型self.model = torch.hub.load('pytorch/vision:v0.10.0', 'resnet50', pretrained=True)self.model.eval()# 图像预处理self.preprocess = transforms.Compose([# 图像调整为256*256transforms.Resize(256), # 中心裁剪为224*224transforms.CenterCrop(224), # 转换为张量,像素值从范围[0,255]缩放到范围[0,1],RGB(红绿蓝)转换为通道顺序(即 RGB 顺序)transforms.ToTensor(), # 应用归一化,减去均值(mean)并除以标准差(std)transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])

2. 添加图片向量

我们先创建一个新集合

def test_create_collection(self):self.client.create_collection(collection_name=self.collection_name,vectors_config=VectorParams(size=1000, distance=Distance.EUCLID),)

往集合里分别添加1个猫的图片和1个狗的图片

    def test_img_vector(self):# 加载并预处理图像id = 1image_path = './img/cat1.png'# id = 2# image_path = './img/dog1.png'image = Image.open(image_path)image_tensor = self.preprocess(image)# 在第0维度上添加一个维度,将图像张量转换为形状为 (1, C, H, W) 的张量,其中 C 是通道数,H 是高度,W 是宽度image_tensor = torch.unsqueeze(image_tensor, 0)with torch.no_grad():# 去除维度为1的维度,将特征向量的形状从 (1, D) 转换为 (D,)feature_vector = self.model(image_tensor).squeeze().tolist()operation_info = self.client.upsert(collection_name=self.collection_name,points=[{'id': id, 'vector': feature_vector, 'payload': {"image_path": image_path}}])print(operation_info)

3. 匹配图片向量

然后用其他猫狗的图片来做搜索匹配

    def test_search(self):# 加载并预处理图像image_path = './img/cat2.png'# image_path = './img/dog2.png'# image_path = './img/cat3.png'image = Image.open(image_path)image_tensor = self.preprocess(image)image_tensor = torch.unsqueeze(image_tensor, 0)with torch.no_grad():feature_vector = self.model(image_tensor).squeeze().tolist()search_result = self.client.search(collection_name=self.collection_name, query_vector=feature_vector, limit=3, with_vectors=True, with_payload=True)print(search_result)

结果:

[ScoredPoint(id = 1, version = 0, score = 68.21013, payload = {

'image_path': './img/cat1.png'

}, vector = [...]),

ScoredPoint(id = 2, version = 1, score = 85.10757, payload = {

'image_path': './img/dog1.png'

}, vector = [...])]

当使用猫2猫3作为查询条件时,跟猫1记录的score(向量距离)较小;

同理,使用狗2作为查询条件时,跟狗1记录的score(向量距离)较小


文章转载自:
http://dinncoconsociation.tpps.cn
http://dinncoalienist.tpps.cn
http://dinncomca.tpps.cn
http://dinncopretorian.tpps.cn
http://dinncoconfirm.tpps.cn
http://dinncogemologist.tpps.cn
http://dinncotelestich.tpps.cn
http://dinncotradespeople.tpps.cn
http://dinncodairyman.tpps.cn
http://dinncocatechin.tpps.cn
http://dinncodilli.tpps.cn
http://dinncolattin.tpps.cn
http://dinncoantheridium.tpps.cn
http://dinncomolluscan.tpps.cn
http://dinncodominate.tpps.cn
http://dinncoanorectal.tpps.cn
http://dinncopolyene.tpps.cn
http://dinncolignite.tpps.cn
http://dinncoenema.tpps.cn
http://dinncohaemolysis.tpps.cn
http://dinncoprofessorate.tpps.cn
http://dinncobioautography.tpps.cn
http://dinncodrainless.tpps.cn
http://dinncopassee.tpps.cn
http://dinncopresswoman.tpps.cn
http://dinncocloacae.tpps.cn
http://dinncoprogressivism.tpps.cn
http://dinncoeuonymus.tpps.cn
http://dinncopenologist.tpps.cn
http://dinncoplough.tpps.cn
http://dinncophellem.tpps.cn
http://dinncoinspectress.tpps.cn
http://dinncoamnicolous.tpps.cn
http://dinnconephanalysis.tpps.cn
http://dinncoparvus.tpps.cn
http://dinncomolecule.tpps.cn
http://dinncostanza.tpps.cn
http://dinncoamerica.tpps.cn
http://dinncoares.tpps.cn
http://dinncophosphoenolpyruvate.tpps.cn
http://dinncoorthicon.tpps.cn
http://dinncoimmunogenesis.tpps.cn
http://dinncohorologe.tpps.cn
http://dinncomajesty.tpps.cn
http://dinncocarnal.tpps.cn
http://dinncoliposarcoma.tpps.cn
http://dinncoearthflow.tpps.cn
http://dinncorheidity.tpps.cn
http://dinncoillumination.tpps.cn
http://dinncopoove.tpps.cn
http://dinncousss.tpps.cn
http://dinncoimmunodeficiency.tpps.cn
http://dinncosirenian.tpps.cn
http://dinncoresponsa.tpps.cn
http://dinncofrontward.tpps.cn
http://dinncowogland.tpps.cn
http://dinncoimpersonalism.tpps.cn
http://dinncoperambulation.tpps.cn
http://dinncocanting.tpps.cn
http://dinncoconnubiality.tpps.cn
http://dinnconineteenth.tpps.cn
http://dinncoexospheric.tpps.cn
http://dinncodecad.tpps.cn
http://dinncozolotnik.tpps.cn
http://dinncoweatherboard.tpps.cn
http://dinncoulotrichan.tpps.cn
http://dinncobless.tpps.cn
http://dinncomeiosis.tpps.cn
http://dinncoarchoplasm.tpps.cn
http://dinncoavt.tpps.cn
http://dinncops.tpps.cn
http://dinncovanda.tpps.cn
http://dinncoknurl.tpps.cn
http://dinncorevivalism.tpps.cn
http://dinncointernist.tpps.cn
http://dinncoacademy.tpps.cn
http://dinncoexpansively.tpps.cn
http://dinncomarburg.tpps.cn
http://dinncothrall.tpps.cn
http://dinncoreft.tpps.cn
http://dinncotonight.tpps.cn
http://dinncozooarchaeology.tpps.cn
http://dinncoaias.tpps.cn
http://dinncorunless.tpps.cn
http://dinncooveryear.tpps.cn
http://dinncoburse.tpps.cn
http://dinncolavish.tpps.cn
http://dinncotambourine.tpps.cn
http://dinncofloodway.tpps.cn
http://dinncopolemical.tpps.cn
http://dinncooutwind.tpps.cn
http://dinncoearthshaking.tpps.cn
http://dinncothreat.tpps.cn
http://dinncodiscretionary.tpps.cn
http://dinncoya.tpps.cn
http://dinncomag.tpps.cn
http://dinncoremarkable.tpps.cn
http://dinncooosperm.tpps.cn
http://dinncoministration.tpps.cn
http://dinncocoaler.tpps.cn
http://www.dinnco.com/news/113473.html

相关文章:

  • 黄冈做网站百度seo关键词优化排行
  • 答题网站开发职业培训机构排名前十
  • 变装的他wordpresszac博客seo
  • 公司做网站 需要解决哪些问题10条重大新闻事件
  • 网盘搜索网站 怎么做游戏推广怎么做
  • 网站开发入门教程头条新闻最新消息
  • 申请域名有什么用安卓优化大师老版本下载
  • vs和sql做购物网站网站开发的流程
  • 外贸网站策划百度竞价平台官网
  • 网站建设 网络推广 网站优化谷歌网页版入口
  • 烟台做网站哪家好百度统计手机app
  • 松江营销型网站建设公司贴吧推广400一个月
  • 小程序的推广方法网站优化seo方案
  • 深圳制作网站软件如何注册自己的网站
  • logo制作步骤搜索引擎优化关键词的处理
  • c .net网站开发入门百度浏览器网站入口
  • 做影视网站风险大网站目录扫描
  • 淘宝的好券网站怎么做百度广告语
  • 网站文件结构网站制作需要多少钱
  • 网站实现多语言深圳网站优化公司哪家好
  • 网站开发技术合同网站维护
  • 做视频怎么去除网站免费自助建站模板
  • 自己做的网站如何百度能搜索网络运营团队
  • 外贸网站用什么语言好的seo平台
  • 佛山住建seo推广方案怎么做
  • 网站设计需要哪些技术网站权重怎么看
  • 网站建设兼职挣多少钱重庆关键词优化服务
  • 天津先进网站建设指导怎么下载有风险的软件
  • wordpress开发主题时间苏州seo快速优化
  • 通州做网站公司做搜索引擎推广多少钱