CLIP-Count代码配置以及踩坑记录

代码:https://github.com/songrise/CLIP-Count

下载好后安装一下特定的包,主要麻烦的是clip包,clip包不能用

pip install clip

这个是错的,下载好了运行会报错。下面是正确的按照方式

pip install ftfy # 这个包也要装
pip install git+https://github.com/openai/CLIP.git  # 装clip 的代码

如果电脑是内网环境,先下载CLIP的源码,然后解压,解压后进入clip目录。GitHub - openai/CLIP: CLIP (Contrastive Language-Image Pretraining), Predict the most relevant text snippet given an image

假设目录名为CLIP,如图。终端输入命令:

python -u setup.py install 

然后就安装好了,装的是clip1.0

数据集配置没啥问题,train一定要 FSC-147 

下载路径: https://drive.google.com/file/d/1ymDYrGs9DSRicfZbSCDiOu0ikGDh5k6S/view?usp=sharing

FSC-147注释路径:https://github.com/cvlab-stonybrook/LearningToCountEverything/tree/master/data 

把data文件夹下下来,放在你的主文件路径下如下:

data
├─CARPK/
│  ├─Annotations/
│  ├─Images/
│  ├─ImageSets/
│
├─FSC/    
│  ├─gt_density_map_adaptive_384_VarV2/
│  ├─images_384_VarV2/
│  ├─FSC_147/
│  │  ├─ImageClasses_FSC147.txt
│  │  ├─Train_Test_Val_FSC_147.json
│  │  ├─ annotation_FSC147_384.json
│  
├─ShanghaiTech/
│  ├─part_A/
│  ├─part_B/

FSC下下来的和代码实际运行的还有点区别,自己改一下数据集里的名字就行了。

这样基本就可以train了。

如果内网环境,models/clip_count.py里的self.clip, clip_preprocess报错,改成本地路径下载好的pt即可。

        if backbone == "b16":
            # self.clip, clip_preprocess = clip.load("ViT-B/16")
            self.clip, clip_preprocess = clip.load("/path/CLIP-Count-main/ViT-B-16.pt")
            self.n_patches = 14*14
            self.clip_hidden_dim = 768
            self.clip_out_dim = 512

VIT-B-16.pt下载路径是:

https://openaipublic.azureedge.net/clip/models/5806e77cd80f8b59890b7e101eabd078d9fb84e6937f9e85e4ecb61988df416f/ViT-B-16.pt

最后,运行主目录下run.py即可。

python -u run.py 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值