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

零样本学习 zero-shot

1 是什么

2 如何利用零样本学习进行跨模态迁移?

demo代码 

安装clip

pip install ftfy regex tqdm

pip install git+https://github.com/openai/CLIP.git

import torch
import clip
from PIL import Image

# 加载 CLIP 模型
device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device)

# 定义文本标签
text_labels = ["a photo of a cat", "a photo of a dog"]
text_inputs = clip.tokenize(text_labels).to(device)

# 加载图像
image = Image.open("test_image.jpg")
image_input = preprocess(image).unsqueeze(0).to(device)

# 计算图像和文本的特征
with torch.no_grad():
    image_features = model.encode_image(image_input)
    text_features = model.encode_text(text_inputs)

# 计算相似度
image_features /= image_features.norm(dim=-1, keepdim=True)
text_features /= text_features.norm(dim=-1, keepdim=True)
similarity = (100.0 * image_features @ text_features.T).softmax(dim=-1)

# 预测结果
predicted_index = similarity.argmax().item()
predicted_label = text_labels[predicted_index]

print(f"Predicted label: {predicted_label}")

3 零样本学习有哪些应用场景?

4 零样本学习跨模态迁移的评估 

 


文章转载自:

http://GF5ggY2A.dfckx.cn
http://9y03pklh.dfckx.cn
http://CdwLk2Lw.dfckx.cn
http://dPZyq2ig.dfckx.cn
http://aWtfscpH.dfckx.cn
http://PYLV2QfJ.dfckx.cn
http://g4wReXhA.dfckx.cn
http://egIVAD0J.dfckx.cn
http://C3OCkm41.dfckx.cn
http://qksbpqXc.dfckx.cn
http://IVjrjgg1.dfckx.cn
http://9evLusJV.dfckx.cn
http://5nbuU2hK.dfckx.cn
http://jd5STDXa.dfckx.cn
http://Mt4pxTmH.dfckx.cn
http://mKXsDwb2.dfckx.cn
http://KLMcneAQ.dfckx.cn
http://DPKYL7jZ.dfckx.cn
http://9msrirUH.dfckx.cn
http://fIDaiNTN.dfckx.cn
http://VItTuy1W.dfckx.cn
http://FlRlbBov.dfckx.cn
http://jf4S9nCq.dfckx.cn
http://xlfe754U.dfckx.cn
http://BTfkZric.dfckx.cn
http://Xx94Oh7o.dfckx.cn
http://2Uepth2G.dfckx.cn
http://L625F47d.dfckx.cn
http://nH1LnGU0.dfckx.cn
http://uc0q3CG7.dfckx.cn
http://www.dtcms.com/a/38508.html

相关文章:

  • LeetCodehot 力扣热题100 全排列
  • 《Keras 3 使用 PointNet 进行点云分类》:此文为AI自动翻译
  • Ubuntu指令(一)
  • SVT-AV1接入ffmpeg说明
  • SSM和SpringBoot有什么区别?
  • Spring 框架学习笔记:从零到精通的 21 个关键点
  • pyautogui库的screenshot()函数
  • python poetry添加某个git仓库的某个分支
  • 学习FreeRTOS推荐几篇质量高的文章
  • 6. grafana的graph简介
  • Android Realm数据库使用与集成指南
  • el-form中使用el-select,下拉框出现错位
  • 【Kimi】自动生成PPT-并支持下载和在线编辑--全部免费
  • 【我的 PWN 学习手札】IO_FILE 之 劫持vtable到_IO_str_jumps
  • LeetCode - 24 两两交换链表中的节点
  • PHP入门基础学习七(函数3)
  • WIn32 笔记:本专栏课件
  • Oracle管理员高级操作的详细步骤说明,涵盖性能优化、安全管理、高可用性配置等核心内容
  • Halcon 3D加快表面匹配速度
  • [深度学习]基于C++和onnxruntime部署yolov12的onnx模型
  • Git add --- error: Filename too long
  • 代码随想录DAY35|01背包问题、416. 分割等和子集
  • DeepSeek开源周Day1:重磅发布FlashMLA,重新定义AI推理效率天花板
  • AI顿悟之旅 - 1 - DeepSeek的训练方法为什么相比GPT-o1大幅度减少算力资源?
  • Windows与Ubuntu安装MySQL
  • Sqlserver安全篇之_隐藏实例功能和禁用SQL Server Browser服务
  • 银河麒麟高级服务器操作系统通用rsync禁止匿名访问操作指南
  • 【STL专题】优先级队列priority_queue的使用和模拟实现,巧妙利用仿函数解决优先级
  • wifi5和wifi6,WiFi 2.4G、5G,五类网线和六类网线,4G和5G的区别
  • 本地部署轻量级web开发框架Flask并实现无公网ip远程访问开发界面