工业异常检测AnomalyGPT复现
为上一版作补充,链接如下:
demo部分:
工业异常检测AnomalyGPT-Demo试跑-CSDN博客
train部分:
工业异常检测AnomalyGPT-训练试跑及问题解决_valueerror: no slot '1' specified on host 'localho-CSDN博客
官方论文:AnomalyGPT: Detecting Industrial Anomalies Using Large Vision-Language Models
官方代码:GitHub - CASIA-IVA-Lab/AnomalyGPT: [AAAI 2024 Oral] AnomalyGPT: Detecting Industrial Anomalies Using Large Vision-Language Models
1.环境
git clone https://github.com/CASIA-IVA-Lab/AnomalyGPT.git
conda create -n ano python=3.8
conda activate ano
进入 AnomalyGPT-main/
pip install -r requirement.txt
2.数据集权重
数据集和权重按官网下载即可
另vicuna的权重是由llama和vicuna的delta权重合并而来,详细过程看官网
3.演示
需要指定路径,在web_demo.py中

进入code路径下
python web_demo.py
4.训练
方式1:提前修改train_mvtec.py文件

如果有四张卡
deepspeed --include localhost:0,1,2,3 --master_port 28400 train_mvtec.py
如果只有一张卡 (以此类推
deepspeed --include localhost:0 --master_port 28400 train_mvtec.py
当你修改卡的数量后,还要修改code/dsconfig路径下
openllama_peft_stage_1.json文件中的batchsize(默认为8)
满足 train_batch_size = train_micro_batch_size_per_gpu * gradient_accumulation_steps
方式2:编辑code/scripts/train_mvtec.sh
同方式1修改路径
在code/scripts路径下
bash train_mvtec.sh
运行截图

问题部分!!
1.运行web_demo的问题:
(1)ImportError: libGL.so.1: cannot open shared object file: No such file or dir...
pip install opencv-python-headless
(2)requests.exceptions.ReadTimeout: HTTPConnectionPool(host='xx.xx.xx.xx', port=xxxx): Read timed out. (read timeout=3)
export no_proxy="localhost,127.0.0.1,::1"
(3)如果本机无法打开127.0.0.1可以使用gradio包,会生成一个72h有效的网站
登录账号username ,密码password,可自行修改
需要在web_demo.py加入
demo.launch(share=True, auth=("username", "password"))
2.运行train_mvtc的问题:
(1)AssertionError: CUDA_HOME does not exist, unable to compile CUDA op(s)
conda install -c nvidia cuda-compiler
(2) ModuleNotFoundError: No module named 'skimage'
pip install scikit-image
(3)ubprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.
sudo apt-get install make gcc g++
sudo apt-get install manpages-dev
g++ --version
(4)NameError: name 'LlamaTokenizer' is not defined
在AnomalyGPT/code/model/openllama.py中加
from transformers import LlamaTokenizer
(5)loraconfig找不到
在AnomalyGPT/code/model/openllama.py中加
from peft import LoraConfig, TaskType, get_peft_model
(6)TypeError: 'NoneType' object is not subscriptable
一般前面还会有Caught TypeError in DataLoader worker process 6

我更换了image数据集和pandagpt4_visual_instruction_data.json以及mvtec数据集
目前就是遇到了这些错误,感谢@独鹿的文章。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)