littlebot
Published on 2025-04-03 / 0 Visits
0

【源码】基于Python和CLIP框架的ZeroShot算法提升项目

项目简介

本项目借助Clip(ViT-B/32, RN50x16)和SAM模型,运用test-time-training方式,在Refcoco、Refcoco+数据集上对zero-shot算法效果进行提升。通过精心设计的prompt调整和基于统计的方法,有效增强了算法效果,且在2023年第五届全球人工智能校园算法精英大赛中荣获全国二等奖(rank 10)。

项目的主要特性和功能

  1. Zero-Shot算法提升:利用Clip(ViT-B/32, RN50x16)和SAM模型,在Refcoco、Refcoco+数据集上优化zero-shot算法效果。
  2. Test-Time-Training:对文本端和视觉端进行prompt调整,提高模型性能。
  3. 基于统计的方法:引入动态调整颜色宽度、基于统计的方法等,进一步提升算法效果。
  4. 比赛获奖:在2023年第五届全球人工智能校园算法精英大赛中获得全国二等奖(rank 10)。

安装使用步骤

假设用户已经下载了本项目的源码文件。 1. 安装依赖: bash pip install -r requirements.txt 2. 下载SAM模型:将SAM模型下载至 models/ 文件夹下。 - SAM模型官方下载链接: https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth 3. 运行项目: - 通过调用shell脚本运行: bash bash run.sh - 或直接运行 main.pybash CUDA_VISIBLE_DEVICES=0 python main.py \ --input_file 'data/testa/annos.jsonl' \ --detector_file 'data/dets_dict.json' \ --image_root 'data/testa/images' \ --clip_model 'ViT-B/32,RN50x16' \ --results_path 'result/result_testa.json' \ --cache_path 'cache/test' \ --box_representation_method 'blur,circle,crop,gray,edge,blur-circle,gray-circle' \ --method 'baseline' \ --device 0 \ --dynamic_color_width True \ --fine_grained True \ --sam_cache_path 'cache/sam' \ --sam_temp_path 'cache/sam_tmp' \ --resize_square True \ --enlarge_boxes 0 \ --size_Q 300 \ --box_area_threshold 0.06 \ --img_cache_path 'cache/img'

数据集

数据集下载链接:https://pan.baidu.com/s/1CBcOio3p23TPGSJhrD32Rw?pwd=55w2 相关说明详见 data/readme.md

注意事项

  • 运行时需要至少60GB内存和48GB显存。
  • 运行时会自动生成大量缓存文件,运行结束后可删除。
  • 如果运行中由于内存或显存不足导致进程中断,可以重新运行,程序将从中断的位置继续运行。

下载地址

点击下载 【提取码: 4003】【解压密码: www.makuang.net】