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

建德营销型网站建设wordpress 4.9.6 zh

建德营销型网站建设,wordpress 4.9.6 zh,做包装用哪个网站,企业网站建设栏目结构图OpenAI——CLIPs(打通NLP与CV) Open AI在2021年1月份发布Contrastive Language-Image Pre-training(CLIP),基于对比文本-图像对对比学习的多模态模型#xff0c;通过图像和它对应的文本描述对比学习#xff0c;模型能够学习到文本-图像对的匹配关系。它开源、多模态、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 pytorch1.7.1 torchvision cudatoolkit11.0 $ pip install ftfy regex tqdm $ pip install githttps://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, devicedevice)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, keepdimTrue)text_features model.encode_text(text) # 将文本进行编码text_features / text_features.norm(dim-1, keepdimTrue)# 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, keepdimTrue)# 计算图片和问题之间的匹配分数(矩阵相乘)sc float((image_features textp_embeddings.T).cpu().numpy())score.append(sc)print(pd.DataFrame({texts: texts, score: score}).sort_values(score, ascendingFalse))print()print(-------------------------)print()二transformer库版本 Transformers 库的基本使用 https://blog.csdn.net/benzhujie1245com/article/details/125279229 安装 pip install transformersCLIP源码 ####基本用法二:利用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(texttext,images image,return_tensorspt,paddingTrue) outputs model(**inputs) logits_per_image outputs.logits_per_image probs logits_per_image.softmax(dim1)for i in range(len(text)):print(text[i],:,probs[0][i])输入图片 结果 但是CLIP对于有些比较抽象的图片或任务效果并不一定好例如 图片code.png PLUS 但是CLIP仍是一项AI重要突破尤其是当它应用到CV相关任务时例如风格换装CLIPBERTCLIP4ClipCLIP2VideoCLIPTV、image caption等等。
http://www.hkea.cn/news/14457489/

相关文章:

  • 广州17网站一起做网店网页上传wordpress
  • 宝安住房和建设局网站电话主网站下建立子目录站
  • 大学生做爰网站国内十大电商平台排名
  • php做原生直播网站怎么在app中嵌入h5页面
  • 深圳网站(建设信科网络)wordpress 中文视频教程
  • 绿色系的网站怀化订水网站
  • 竹木工艺品网站建设wordpress 批量创建目录结构
  • 网站备案现场河南省建设厅网站打不开
  • 广西柳州网站建设推荐永久域名申请
  • 网站建设规划书主题网站建设平台方案设计
  • 落实网站建设管理网站开发好吗
  • 怎么看别的网站是那个公司做的北京电商平台网站建设
  • 网站开发基础与提高网站域名改版怎么做
  • 广州网站建设设计哪家好抚州网络推广
  • 网站建设要哪些工作西安网页制作
  • wordpress 更换空间阿里云网站优化链接
  • 靖江网站建设制作如何选择宣传片制作
  • 苏州市做网站做的较好的拍卖网站
  • 网站建设找宙斯站长工具怎么把网站上线
  • 哪里有专门做gif的网站群晖wordpress默认地址
  • 加大门户网站安全制度建设查工程中标信息哪个网站
  • 鄂尔多斯网站制作 建设京东网站建设吗
  • 青浦php网站开发培训软件开发主要几个步骤
  • 公司网站建设步骤栾川网站建设
  • 企业门户网站开发平台的设计与实现培训机构官网
  • 网站开发与设计论文seo公司外包
  • html嵌入网站企业代运营公司
  • 美食网站素材刚刚发生 北京严重发生
  • 网站换行代码短网址生成器是什么
  • 网站开发还找到工作吗网站左侧的导航是怎么做的