A concise and unified toolkit for Anomaly Detection's Training, Evalutation, Prediction and Export (AD-TEPE).
Project description
异物检测AD-TEPE
A concise and unified toolkit for Anomaly Detection's Training, Evalutation, Prediction and Export (AD-TEPE).
The supported algorithms are as follows,
- anomaly detection:
- CFA
- RD
环境安装
可以直接运行下列命令,本地conda环境配置和服务器docker使用详见:环境安装
## step1 克隆仓库到ad-tepe文件夹下
git clone -b anomaly_detection git@10.106.249.57:SD/tepe.git ad-tepe
## step2 转到ad-tepe目录下
cd ad-tepe
## step3 安装相关依赖
pip install -r requirements.txt
## step4 将tepe依赖安装到环境中
pip install -v -e . # or "python setup.py develop"
异物检测数据集格式
参考公开数据集MVTec格式
data_root
├── scene1
│ ├── train
│ │ └── good
│ │ ├── 000000000001.jpg
│ │ ├── 000000000002.jpg
│ │ ...
│ │ └── 000000001111.jpg
│ └── test
│ ├── good
│ │ ├── 000000002222.jpg
│ │ ├── 000000002223.jpg
│ │ ...
│ │ └── 000000004444.jpg
│ ├── bad1
│ │ ├── 000000003333.jpg
│ │ ├── 000000003334.jpg
│ │ ...
│ │ └── 000000005555.jpg
│ ├── bad2
│ ...
├── scene2
│ ├── train
│ │ └── good
│ │ │
│ │ ...
│ └── test
│ ├── good
│ │ │
│ │ ...
│ ├── bad1
│ │ │
│ │ ...
│ ├── bad2
│ ...
└── scene3
│
...
快速使用
1. 创建配置文件
参考configs/anomaly_detection目录下的配置文件,复制/创建一个自己需要的config.py文件,它既可以当作配置文件,也可以当作程序运行的入口。它里面包含一个任务配置类,这个类需要继承一个默认的配置类,默认配置类在tepe/tasks/*/task.py中实现。
以cfa检测算法为例:
## config.py
from tepe.tasks.cfa import CFAConfig
class TaskConfig(CFAConfig):
def __init__(self):
super(TaskConfig, self).__init__()
self.task_name = 'cfa_eguo' # 任务名称,输出文件夹以这个命名
self.data_root = '/home/zepei/DATA/yiwushuju/image' # 数据集路径
self.scene = 'eguo' # 数据集中场景名称
self.max_epoch = 30 # 最大迭代轮数
self.input_size = [320, 512] # 输入分辨率
self.batch_size = 4
self.keep_ratio = False
2. 调用配置文件
有两种调用方式:
方法一:使用命令行
# 训练 (train)
tepe train -t {config.py}
# 验证 (evaluate)
tepe eval -t {config.py} -w {trained_weights}
# 预测 (predict)
tepe predict -t {config.py} -s {img|fold|video} -w {trained_weights}
# 导出 (export)
tepe export -t {config.py} -w {trained_weights}
方法二:直接运行config.py
只需要在config.py中实现main入口,去实例化你的任务类,
## config.py
from tepe.tasks.cfa import CFAConfig
class TaskConfig(CFAConfig):
...
# 运行此py文件入口
if __name__ == '__main__':
task = TaskConfig()
# 训练
task.train()
# 评估
task.eval()
# 导出
task.export()
# 预测
task.weights = "" # 模型文件
source = "" # 图片/文件/视频/等
view_img = True # 是否可视化结果
save_img = True # 是否保存预测结果
task.predict(source=source, view_img=view_img, save_img=save_img)
更新日志:
[2022/09/22] 新的功能: 可以通过http请求来进行存图片,训练,导出,预测等操作
[2022/09/14] 实现了异常检测(anomaly detection)知识蒸馏算法rd的训练train和导出export
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tepe-0.6.10-py3-none-any.whl.
File metadata
- Download URL: tepe-0.6.10-py3-none-any.whl
- Upload date:
- Size: 267.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ea028b7350de800e8aba1cf2a2ef313c77ec6fec6eaf9b30acd117534c4a97e
|
|
| MD5 |
7a67a3d44128242d4c110ccc50420a2b
|
|
| BLAKE2b-256 |
85b389467688112d786fcdc06e766102496cfdfa98a37619b89d7ea0cd282e99
|