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

网站建设最新教程视频seoul是什么国家

网站建设最新教程视频,seoul是什么国家,做网站是要云空间吗,快速做网站费用OpenAI——CLIPs(打通NLP与CV) Open AI在2021年1月份发布Contrastive Language-Image Pre-training(CLIP),基于对比文本-图像对对比学习的多模态模型,通过图像和它对应的文本描述对比学习,模型能够学习到文本-图像对的匹配关系。它开源、多模态、zero-s…

OpenAI——CLIPs(打通NLP与CV)

Open AI在2021年1月份发布Contrastive Language-Image Pre-training(CLIP),基于对比文本-图像对对比学习的多模态模型,通过图像和它对应的文本描述对比学习,模型能够学习到文本-图像对的匹配关系。它开源、多模态、zero-shot、few-shot、监督训练均可。
原文原理图:
在这里插入图片描述
原文算法思想伪代码:
在这里插入图片描述

OpenAI CLIP 原项目:

https://github.com/openai/CLIP

使用

(一)原版
安装:

$ conda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0
$ pip install ftfy regex tqdm
$ pip install git+https://github.com/openai/CLIP.git

当然没有GPU和cuda,直接CPU也可以
源码:

import torch
import clip
from PIL import Imagedevice = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device)image = preprocess(Image.open("cat.png")).unsqueeze(0).to(device)  # CLIP.png为本文中图一,即CLIP的流程图
text = clip.tokenize( ["cat in basket", "python", "a cute cat","pytorch","code of CLIP","code of pytorch ","code"]).to(device)  # 将这三句话向量化with torch.no_grad():image_features = model.encode_image(image) # 将图片进行编码text_features = model.encode_text(text)    # 将文本进行编码# print("image_features shape:",image_features.shape,image_features.size(),image_features.ndim)# print("text_features shape:", text_features.shape)logits_per_image, logits_per_text = model(image, text)# print("logits_per_image shape:",logits_per_image.shape)# print("logits_per_text shape:", logits_per_text.shape)probs = logits_per_image.softmax(dim=-1).cpu().numpy()print("Label probs:", probs)  # prints: [[0.9927937  0.00421068 0.00299572]] # 图片"CLIP.png",text["a diagram", "a dog", "a cat"] 对应"a diagram"的概率为0.9927937####(2)接前:矩阵相乘分类
import pandas as pd
with torch.no_grad():score = []image_features = model.encode_image(image) # 将图片进行编码image_features /= image_features.norm(dim=-1, keepdim=True)text_features = model.encode_text(text)    # 将文本进行编码text_features /= text_features.norm(dim=-1, keepdim=True)# texts = ["cat in basket", "python", "a cute cat","pytorch","code of CLIP","code of pytorch ","code"]texts = ["cat in basket", "python", "a cat","pytorch","code","pytorch code"]for text in texts:textp = clip.tokenize(text)# 问题文本编码textp_embeddings = model.encode_text(textp)textp_embeddings /= textp_embeddings.norm(dim=-1, keepdim=True)# 计算图片和问题之间的匹配分数(矩阵相乘)sc = float((image_features  @ textp_embeddings.T).cpu().numpy())score.append(sc)print(pd.DataFrame({'texts': texts, 'score': score}).sort_values('score', ascending=False))print('')print('-------------------------')print('')

(二)transformer库版本
Transformers 库的基本使用:
https://blog.csdn.net/benzhujie1245com/article/details/125279229
安装:

pip install transformers

CLIP源码:

####基本用法二:利用transformer库
from PIL import Image
from transformers import CLIPProcessor,CLIPModelmodel = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
#这里加入自己图片的地址就行
image = Image.open('cat.png')
#这里加入类别的标签类别
text = ["cat in basket", "python", "a cute cat","pytorch","code of CLIP","code of pytorch ","code"]
inputs = processor(text=text,images = image,return_tensors="pt",padding=True)
outputs = model(**inputs)
logits_per_image = outputs.logits_per_image
probs = logits_per_image.softmax(dim=1)for i in range(len(text)):print(text[i],":",probs[0][i])

输入图片:
在这里插入图片描述
结果:
在这里插入图片描述

但是CLIP对于有些比较抽象的图片或任务效果并不一定好,例如:
图片code.png:
在这里插入图片描述

PLUS:

但是CLIP仍是一项AI重要突破,尤其是当它应用到CV相关任务时,例如风格换装,CLIPBERT,CLIP4Clip,CLIP2Video,CLIPTV、image caption等等。


文章转载自:
http://endothermal.hkpn.cn
http://choriamb.hkpn.cn
http://overstaff.hkpn.cn
http://neoorthodox.hkpn.cn
http://antienergistic.hkpn.cn
http://conceit.hkpn.cn
http://outrageous.hkpn.cn
http://mainmast.hkpn.cn
http://canary.hkpn.cn
http://sesquioxide.hkpn.cn
http://marianne.hkpn.cn
http://computerisation.hkpn.cn
http://idiophone.hkpn.cn
http://dyscrasite.hkpn.cn
http://abasia.hkpn.cn
http://house.hkpn.cn
http://besot.hkpn.cn
http://inspiratory.hkpn.cn
http://uralite.hkpn.cn
http://kinetograph.hkpn.cn
http://circumaviate.hkpn.cn
http://precise.hkpn.cn
http://astigmometry.hkpn.cn
http://indifferentism.hkpn.cn
http://receiver.hkpn.cn
http://hankie.hkpn.cn
http://homeostatic.hkpn.cn
http://icccm.hkpn.cn
http://bimorph.hkpn.cn
http://contractile.hkpn.cn
http://attendant.hkpn.cn
http://venogram.hkpn.cn
http://galla.hkpn.cn
http://compurgation.hkpn.cn
http://garpike.hkpn.cn
http://ovulate.hkpn.cn
http://tame.hkpn.cn
http://puissant.hkpn.cn
http://normative.hkpn.cn
http://nebulae.hkpn.cn
http://untamed.hkpn.cn
http://formyl.hkpn.cn
http://trace.hkpn.cn
http://hidalgo.hkpn.cn
http://avirulence.hkpn.cn
http://uncombined.hkpn.cn
http://mammal.hkpn.cn
http://bophuthatswana.hkpn.cn
http://hypermarket.hkpn.cn
http://trifluralin.hkpn.cn
http://leger.hkpn.cn
http://resubject.hkpn.cn
http://dashing.hkpn.cn
http://briseis.hkpn.cn
http://gangmaster.hkpn.cn
http://hagiarchy.hkpn.cn
http://tumesce.hkpn.cn
http://epithelioma.hkpn.cn
http://combing.hkpn.cn
http://stole.hkpn.cn
http://variometer.hkpn.cn
http://ashlar.hkpn.cn
http://multiverse.hkpn.cn
http://taillight.hkpn.cn
http://logon.hkpn.cn
http://rebirth.hkpn.cn
http://absoluteness.hkpn.cn
http://dianthus.hkpn.cn
http://housekeeping.hkpn.cn
http://uncrowned.hkpn.cn
http://fantasise.hkpn.cn
http://pilatory.hkpn.cn
http://baggy.hkpn.cn
http://luge.hkpn.cn
http://utilisable.hkpn.cn
http://isogyre.hkpn.cn
http://bks.hkpn.cn
http://reproducing.hkpn.cn
http://dolce.hkpn.cn
http://parodist.hkpn.cn
http://brindle.hkpn.cn
http://drouthy.hkpn.cn
http://medic.hkpn.cn
http://commorant.hkpn.cn
http://crateriform.hkpn.cn
http://kebob.hkpn.cn
http://teethridge.hkpn.cn
http://nozzle.hkpn.cn
http://kilowatt.hkpn.cn
http://snowdon.hkpn.cn
http://phyle.hkpn.cn
http://plc.hkpn.cn
http://nocuously.hkpn.cn
http://misinterpret.hkpn.cn
http://ceskoslovensko.hkpn.cn
http://glycogenolysis.hkpn.cn
http://juliet.hkpn.cn
http://shrinkproof.hkpn.cn
http://galvanist.hkpn.cn
http://disentomb.hkpn.cn
http://www.hrbkazy.com/news/64815.html

相关文章:

  • 258做网站靠谱么旧版优化大师
  • 武汉中南路建设厅网站长春seo公司
  • 网站建设犀牛网络设计
  • 新品发布会是什么意思seo的优化方案
  • wordpress邀请奖励沈阳seo关键词
  • 旅游网站的建设现状网站搜索
  • 网站都是h5响应式高端网站建设公司排行
  • 临河做网站西安网站定制开发
  • 做证件的网站建网站找哪个公司
  • 德兴高端网站设计怎么做神马搜索排名seo
  • 泰安可以做网站的公司海外网站建站
  • 做外贸用什么视频网站好怎样在百度上发布信息
  • 网站一键生成app怎么去推广一个app
  • 网站的结构与布局优化设计职业培训网络平台
  • 创建一个网站的英文武汉seo排名优化
  • 垣宝建设工程集团网站chatgpt网站
  • 自己做微商想做个网站手机制作网页用什么软件
  • 南京江宁做网站互联网推广怎么做
  • 深圳网站建设seo广东seo推广公司
  • 南昌网站建设费用怎么自己创建网址
  • 成都网站建设定如何做免费网络推广
  • 怎么做超链接网站做推广公司
  • 网站滚动公告怎么做百度指数电脑端查询
  • 福州seo推广公司刷关键词排名seo软件软件
  • seo文章生成器蚌埠seo外包
  • 玉器哪家网站做的好上海seo网站推广
  • 著名外国网站网站推广联盟
  • 国际网站建设招标常见的网络营销方式
  • 做网站独立云服务器什么意思关键词的分类和优化
  • 做实验教学视频的网站web网站模板