Update README.md
Browse files
README.md
CHANGED
@@ -1,276 +1,213 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
-
|
27 |
-
-
|
28 |
-
-
|
29 |
-
-
|
30 |
-
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# Pre-trained CLIP model
|
80 |
| Model | Download |
|
81 |
-
| --- | --- |
|
82 |
-
| ViT-B/32 | [download](https://openaipublic.azureedge.net/clip/models/40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af/ViT-B-32.pt) |
|
83 |
-
| ViT-B/16 | [download](https://openaipublic.azureedge.net/clip/models/5806e77cd80f8b59890b7e101eabd078d9fb84e6937f9e85e4ecb61988df416f/ViT-B-16.pt) |
|
84 |
| ViT-L/14 | [download](https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt) |
|
85 |
| ViT-L/14@336px | [download](https://openaipublic.azureedge.net/clip/models/3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02/ViT-L-14-336px.pt) |
|
86 |
|
87 |
-
#
|
88 |
-
-
|
89 |
-
```ruby
|
90 |
-
python train.py
|
91 |
-
```
|
92 |
-
- for test with dataset (many data)
|
93 |
-
```ruby
|
94 |
-
python test.py
|
95 |
-
```
|
96 |
-
- for simple test (개별 이미지 테스트)
|
97 |
-
```ruby
|
98 |
-
python Simple_test_code.py
|
99 |
-
```
|
100 |
-
- for UI app test (simple app developed)
|
101 |
-
```ruby
|
102 |
-
python monitor_check.py
|
103 |
-
```
|
104 |
-
- for real-time detection test (webcam and video tracking)
|
105 |
-
```ruby
|
106 |
-
python real_time_CLIP.py
|
107 |
-
```
|
108 |
-
|
109 |
-
# Code Details
|
110 |
-
|
111 |
-
### ✅Dataset configuration
|
112 |
-
|
113 |
-
- Dataset configuration as example below
|
114 |
-
```
|
115 |
-
├── data/
|
116 |
-
│ ├── COMP_1/
|
117 |
-
│ │ ├── product_1/
|
118 |
-
│ │ │ ├──grouth_truth
|
119 |
-
│ │ │ │ ├──anomaly_1
|
120 |
-
│ │ │ │ ├──anomaly_2
|
121 |
-
│ │ │ │
|
122 |
-
│ │ │ ├──test/
|
123 |
-
│ │ │ │ ├──good
|
124 |
-
│ │ │ │ ├──anomaly_1
|
125 |
-
│ │ │ │ ├──anomaly_2
|
126 |
-
│ │ │ │
|
127 |
-
│ │ │ ├──train/
|
128 |
-
│ │ │ │ ├──good
|
129 |
-
│ │ │ │ ├──anomaly_1
|
130 |
-
│ │ │ │ ├──anomaly_2
|
131 |
-
│ │ │ │
|
132 |
-
│ │ ├── product_2/
|
133 |
-
│ │ │ │
|
134 |
-
│ │
|
135 |
-
│ ├── COMP_2/
|
136 |
-
│ │
|
137 |
-
```
|
138 |
-
|
139 |
-
- Generate JSON file storing all the above information of dataset ( -> meta_train.json, meta_test.json)
|
140 |
-
```ruby
|
141 |
-
cd dataset_config
|
142 |
-
python dataset_get_json.py
|
143 |
-
```
|
144 |
-
|
145 |
-
- Making all grouth_truth (only anomaly mask) by hand
|
146 |
-
```ruby
|
147 |
-
cd dataset_config
|
148 |
-
python image_ground_truth.py
|
149 |
-
```
|
150 |
-
|
151 |
-
- Dataset configuration for train and test
|
152 |
-
```ruby
|
153 |
-
cd training_libs
|
154 |
-
python dataset.py
|
155 |
-
```
|
156 |
|
157 |
-
→ _ _init_ _ 메서드는 데이터셋의 루트 디렉토리, 변환 함수, 데이터셋 이름, 모드를 입력으로 받음
|
158 |
-
→ 메타 정보를 담은 JSON 파일 (meta_train.json)을 읽어와 클래스 이름 목록과 모든 데이터 항목을 리스트에 저장
|
159 |
-
→ generate_class_info 함수를 호출하여 클래스 정보를 생성하고 클래스 이름을 클래스 ID에 매핑
|
160 |
-
→ _ _len_ _ 메서드는 데이터셋의 샘플 수를 반환
|
161 |
-
→ _ _getitem_ _ 메서드는 주어진 인덱스의 샘플 데이터를 반환
|
162 |
-
→ 이미지 경로를 통해 이미지를 읽고, 이상 여부에 따라 마스크 이미지를 생성
|
163 |
-
→ 필요시 이미지와 마스크에 변환 함수를 적용
|
164 |
-
→ 이미지, 마스크, 클래스 이름, 이상 여부, 이미지 경로, 클래스 ID를 포함한 딕셔너리를 반환
|
165 |
|
166 |
|
167 |
-
|
168 |
-
```ruby
|
169 |
-
training_lib/utils.py
|
170 |
-
```
|
171 |
-
```ruby
|
172 |
-
AnomalyCLIP_lib/transform.py
|
173 |
-
```
|
174 |
-
⭐ **Data Processing Techniques**
|
175 |
-
1. Normalization
|
176 |
-
→ Standardize image pixel values using mean and standard deviation
|
177 |
-
→ Utilized via *'Normalize'* from *'torchvision.transforms'*
|
178 |
-
|
179 |
-
2. Normalization
|
180 |
-
→ Resize the image to a maximum dimension while maintaining aspect ratio, with padding
|
181 |
-
→ Custom *'ResizeMaxSize'* class
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
→ Implemented via *'RandomResizedCrop'* from *'torchvision.transforms'*
|
186 |
-
|
187 |
-
4. Resize
|
188 |
-
→ Resize images to a fixed size for model input
|
189 |
-
→ Done using *'Resize'* with BICUBIC interpolation
|
190 |
-
|
191 |
-
5. Center Crop
|
192 |
-
→ Crop the central region of the image to the desired size
|
193 |
-
→ Applied using *'CenterCrop'*
|
194 |
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
|
204 |
|
205 |
-
|
206 |
-
1. *'torch'*: Core deep learning library for tensor operations and model building
|
207 |
-
2. *'torchvision'*: Provides image processing utilities like Resize, CenterCrop, Normalize, etc
|
208 |
-
3. *'timm'*: Optional, for advanced augmentation and transformations
|
209 |
-
4. *'AnomalyCLIP_lib'*: Custom library for dataset-specific constants and transformations
|
210 |
|
|
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
|
|
213 |
|
214 |
### ✅ Prompt generating
|
215 |
```ruby
|
216 |
-
|
217 |
-
```
|
218 |
-
👍 **Prompts Built in the Code**
|
219 |
-
1. Normal Prompt: *'["{ }"]'*
|
220 |
-
→ Normal Prompt Example: "object"
|
221 |
-
2. Anomaly Prompt: *'["damaged { }"]'*
|
222 |
-
→ Anomaly Prompt Example: "damaged object"
|
223 |
-
|
224 |
-
👍 **Construction Process**
|
225 |
-
1. *'prompts_pos (Normal)'*: Combines the class name with the normal template
|
226 |
-
2. *'prompts_neg (Anomaly)'*: Combines the class name with the anomaly template
|
227 |
-
|
228 |
-
### ✅ Initial setting for training
|
229 |
-
|
230 |
-
- Define the path to the training dataset and model checkpoint saving
|
231 |
-
```ruby
|
232 |
-
parser.add_argument("--train_data_path", type=str, default="./data/", help="train dataset path")
|
233 |
-
parser.add_argument("--dataset", type=str, default='smoke_cloud', help="train dataset name")
|
234 |
-
parser.add_argument("--save_path", type=str, default='./checkpoint/', help='path to save results')
|
235 |
-
```
|
236 |
-
|
237 |
-
### ✅ Hyper parameters setting
|
238 |
-
|
239 |
-
- Set the depth parameter: depth of the embedding learned during prompt training. This affects the model's ability to learn complex features from the data
|
240 |
-
```ruby
|
241 |
-
parser.add_argument("--depth", type=int, default=9, help="image size")
|
242 |
-
```
|
243 |
-
|
244 |
-
- Define the size of input images used for training (pixel)
|
245 |
-
```ruby
|
246 |
-
parser.add_argument("--image_size", type=int, default=518, help="image size")
|
247 |
-
```
|
248 |
-
|
249 |
-
- Setting parameters for training
|
250 |
-
```ruby
|
251 |
-
parser.add_argument("--epoch", type=int, default=500, help="epochs")
|
252 |
-
parser.add_argument("--learning_rate", type=float, default=0.0001, help="learning rate")
|
253 |
-
parser.add_argument("--batch_size", type=int, default=8, help="batch size")
|
254 |
```
|
255 |
|
256 |
-
|
257 |
-
```ruby
|
258 |
-
parser.add_argument("--dpam", type=int, default=20, help="dpam size")
|
259 |
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
262 |
```
|
263 |
-
|
264 |
-
|
265 |
-
→
|
266 |
-
→
|
267 |
-
→
|
268 |
-
→ If you want to refine the entire model, you can set --dpam to the number of layers in the model (e.g., 12 for ViT-B and 24 for ViT-L).
|
269 |
-
→ If you want to focus only on the final layers (where the model usually learns complex features), you can choose fewer DPAM layers.
|
270 |
```
|
271 |
|
272 |
|
273 |
-
|
274 |
# References
|
275 |
- AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection [[github](https://github.com/zqhang/AnomalyCLIP.git)]
|
276 |
|
|
|
1 |
+
# CLIP 기반 제품 결함 탐지 모델 카드
|
2 |
+
|
3 |
+
## 모델 세부사항
|
4 |
+
|
5 |
+
### 모델 설명
|
6 |
+
|
7 |
+
이 모델은 CLIP 기반의 이상 탐지 방법을 사용하여 제품 결함을 탐지합니다.
|
8 |
+
사전 훈련된 CLIP 모델을 fine-tuning하여 제품 이미지에서 결함을 식별하고, 생산 라인에서 품질 관리 및 결함 감지를 자동화합니다.
|
9 |
+
|
10 |
+
- **Developed by:** 오석
|
11 |
+
- **Funded by:** 4INLAB INC.
|
12 |
+
- **Shared by:** zhou2023anomalyclip
|
13 |
+
- **Model type:** CLIP based Anomaly Detection
|
14 |
+
- **Language(s):** Python, PyTorch
|
15 |
+
- **License:** Apache 2.0, MIT, GPL-3.0
|
16 |
+
|
17 |
+
### 기술적 제한사항
|
18 |
+
|
19 |
+
- 모델은 결함 탐지를 위한 충분하고 다양한 훈련 데이터를 필요로 합니다. 훈련 데이터셋이 부족하거나 불균형할 경우, 모델의 성능이 저하될 수 있습니다.
|
20 |
+
- 실시간 결함 감지 성능은 하드웨어 사양에 따라 달라질 수 있으며, 높은 해상도에서 결함을 탐지하는 정확도가 떨어질 수 있습니다.
|
21 |
+
- 결함이 미세하거나 제품 간 유사성이 매우 높은 경우, 모델이 결함을 정확하게 탐지하지 못할 수 있습니다.
|
22 |
+
|
23 |
+
## 학습 세부사항
|
24 |
+
|
25 |
+
### Hardware
|
26 |
+
- **CPU:** Intel Core i9-13900K (24 Cores, 32 Threads)
|
27 |
+
- **RAM:** 64GB DDR5
|
28 |
+
- **GPU:** NVIDIA RTX 4090Ti 24GB
|
29 |
+
- **Storage:** 1TB NVMe SSD + 2TB HDD
|
30 |
+
- **Operating System:** Windows 11 pro
|
31 |
+
|
32 |
+
### 데이터셋 정보
|
33 |
+
|
34 |
+
이 모델은 시계열 재고 데이터를 사용하여 훈련됩니다. 이 데이터는 재고 수준, 날짜 및 기타 관련 특성에 대한 정보를 포함하고 있습니다.
|
35 |
+
데이터는 Conv1D와 BiLSTM 레이어에 적합하도록 MinMax 스케일링을 사용하여 전처리되고 정규화됩니다.
|
36 |
+
|
37 |
+
|
38 |
+

|
39 |
+
|
40 |
+
- **Data sources:** https://huggingface.co/datasets/quandao92/vision-inventory-prediction-data
|
41 |
+
- **Training size:**
|
42 |
+
- 1차 : Few-shot learning with anomaly (10ea), good (4ea)
|
43 |
+
- 2차 : Few-shot learning with anomaly (10ea), good (10ea)
|
44 |
+
- 3차 : Few-shot learning with anomaly (10ea), good (110ea)
|
45 |
+
|
46 |
+
- **Time-step:** 5초 이내
|
47 |
+
|
48 |
+
- **Data Processing Techniques:**
|
49 |
+
- normalization:
|
50 |
+
description: "이미지 픽셀 값을 평균 및 표준편차로 표준화"
|
51 |
+
method: "'Normalize' from 'torchvision.transforms'"
|
52 |
+
- max_resize:
|
53 |
+
description: "이미지의 최대 크기를 유지하며, 비율을 맞추고 패딩을 추가하여 크기 조정"
|
54 |
+
method: "Custom 'ResizeMaxSize' class"
|
55 |
+
- random_resized_crop:
|
56 |
+
description: "훈련 중에 이미지를 랜덤으로 자르고 크기를 조정하여 변형을 추가"
|
57 |
+
method: "'RandomResizedCrop' from 'torchvision.transforms'"
|
58 |
+
- resize:
|
59 |
+
description: "모델 입력에 맞게 이미지를 고정된 크기로 조정"
|
60 |
+
method: "'Resize' with BICUBIC interpolation"
|
61 |
+
- center_crop:
|
62 |
+
description: "이미지의 중앙 부분을 지정된 크기로 자르기"
|
63 |
+
method: "'CenterCrop'"
|
64 |
+
- to_tensor:
|
65 |
+
description: "이미지를 PyTorch 텐서로 변환"
|
66 |
+
method: "'ToTensor'"
|
67 |
+
- augmentation (optional):
|
68 |
+
description: "데이터 증강을 위해 다양한 랜덤 변환 적용, 'AugmentationCfg'로 설정 가능"
|
69 |
+
method: "Uses 'timm' library if specified"
|
70 |
+
|
71 |
+
|
72 |
+
# AD-CLIP Model Architecture
|
73 |
+
|
74 |
+
|
75 |
+

|
76 |
+
|
77 |
+
- **model:**
|
78 |
+
- input_layer:
|
79 |
+
- image_size: [640, 640, 3] # 표준 입력 이미지 크기
|
80 |
+
- backbone:
|
81 |
+
- name: CLIP (ViT-B-32) # CLIP 모델의 비전 트랜스포머를 백본으로 사용
|
82 |
+
- filters: [32, 64, 128, 256, 512] # 비전 트랜스포머의 각 레이어 필터 크기
|
83 |
+
- neck:
|
84 |
+
- name: Anomaly Detection Module # 결함 탐지를 위한 추가 모듈
|
85 |
+
- method: Contrastive Learning # CLIP 모델의 특징을 사용한 대조 학습 기법
|
86 |
+
- head:
|
87 |
+
- name: Anomaly Detection Head # 결함 탐지를 위한 최종 출력 레이어
|
88 |
+
- outputs:
|
89 |
+
- anomaly_score: 1 # 이상 탐지 점수 (비정상/정상 구분)
|
90 |
+
- class_probabilities: N # 각 클래스에 대한 확률 (결함 여부)
|
91 |
+
|
92 |
+
# Optimizer and Loss Function
|
93 |
+
- **training:**
|
94 |
+
- optimizer:
|
95 |
+
- name: AdamW # AdamW 옵티마이저 (가중치 감쇠 포함)
|
96 |
+
- lr: 0.0001 # 학습률
|
97 |
+
- loss:
|
98 |
+
- classification_loss: 1.0 # 분류 손실 (교차 엔트로피)
|
99 |
+
- anomaly_loss: 1.0 # 결함 탐지 손실 (이상 탐지 모델에 대한 손실)
|
100 |
+
- contrastive_loss: 1.0 # 대조 학습 손실 (유사도 기반 손실)
|
101 |
+
|
102 |
+
# Metrics
|
103 |
+
- **metrics:**
|
104 |
+
- Precision # 정밀도 (Precision)
|
105 |
+
- Recall # 재현율 (Recall)
|
106 |
+
- mAP # 평균 정밀도 (Mean Average Precision)
|
107 |
+
- F1-Score # F1-점수 (균형 잡힌 평가 지표)
|
108 |
+
|
109 |
+
# Training Parameters
|
110 |
+
**하이퍼파라미터 설정**
|
111 |
+
- Learning Rate: 0.001.
|
112 |
+
- Batch Size: 8.
|
113 |
+
- Epochs: 200.
|
114 |
|
115 |
# Pre-trained CLIP model
|
116 |
| Model | Download |
|
|
|
|
|
|
|
117 |
| ViT-L/14 | [download](https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt) |
|
118 |
| ViT-L/14@336px | [download](https://openaipublic.azureedge.net/clip/models/3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02/ViT-L-14-336px.pt) |
|
119 |
|
120 |
+
# Evaluation Parameters
|
121 |
+
- F1-score: 95%이상.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
|
125 |
+
# 학습 성능 및 테스트 결과
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
- **학습성능 결과과 그래프**:
|
128 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
+
<div style="display: flex; justify-content: space-between;">
|
131 |
+
<div style="text-align: center; margin-right: 20px;">
|
132 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/65e7d0935ea025ead9623dde/_lUD77x-yueXycuIn7jya.png" height="80%" width="100%" style="margin-right:5px;">
|
133 |
+
<p>1차 학습 성능</p>
|
134 |
+
</div>
|
135 |
+
<div style="text-align: center; margin-right: 20px;">
|
136 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/65e7d0935ea025ead9623dde/NHDH9N94cI-KqP8k-ASUN.png" height="80%" width="100%" style="margin-right:5px;">
|
137 |
+
<p>2차 학습 성능</p>
|
138 |
+
</div>
|
139 |
+
<div style="text-align: center; margin-right: 20px;">
|
140 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/65e7d0935ea025ead9623dde/6n0DnnQjXD8Ql-p3Owxan.png" height="80%" width="100%" style="margin-right:5px;">
|
141 |
+
<p>3차 학습 성능</p>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
|
145 |
+
- **학습 결과표**:
|
146 |
+

|
147 |
+
|
148 |
+
- **테스트 결과**:
|
149 |
+
<div style="display: flex; justify-content: space-between;">
|
150 |
+
<div style="text-align: center; margin-right: 20px;">
|
151 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/65e7d0935ea025ead9623dde/A91V0GdrcUcX01cC-biG9.png" height="600" width="1000" style="margin-right:5px;">
|
152 |
+
<p>Anomaly Product</p>
|
153 |
+
</div>
|
154 |
+
<div style="text-align: center; margin-right: 20px;">
|
155 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/65e7d0935ea025ead9623dde/PxleIhphzViTGCubVhWn7.png" height="600" width="1000" style="margin-right:5px;">
|
156 |
+
<p>Normal Product</p>
|
157 |
+
</div>
|
158 |
+
</div>
|
159 |
|
160 |
|
161 |
|
162 |
+
# 설치 및 실행 가이라인
|
|
|
|
|
|
|
|
|
163 |
|
164 |
+
이 모델을 실행하려면 Python과 함께 다음 라이브러리가 필요합니다:
|
165 |
|
166 |
+
- **ftfy==6.2.0**: 텍스트 정규화 및 인코딩 문제를 해결하는 라이브러리.
|
167 |
+
- **matplotlib==3.9.0**: 데이터 시각화 및 그래프 생성을 위한 라이브러리.
|
168 |
+
- **numpy==1.24.3**: 수치 연산을 위한 핵심 라이브러리.
|
169 |
+
- **opencv_python==4.9.0.80**: 이미지 및 비디오 처리용 라이브러리.
|
170 |
+
- **pandas==2.2.2**: 데이터 분석 및 조작을 위한 라이브러리.
|
171 |
+
- **Pillow==10.3.0**: 이미지 파일 처리 및 변환을 위한 라이브러리.
|
172 |
+
- **PyQt5==5.15.10**: GUI 애플리케이션 개발을 위한 프레임워크.
|
173 |
+
- **PyQt5_sip==12.13.0**: PyQt5와 Python 간의 인터페이스를 제공하는 라이브러리.
|
174 |
+
- **regex==2024.5.15**: 정규 표현식 처리를 위한 라이���러리.
|
175 |
+
- **scikit_learn==1.2.2**: 기계 학습 및 데이터 분석을 위한 라이브러리.
|
176 |
+
- **scipy==1.9.1**: 과학 및 기술 계산을 위한 라이브러리.
|
177 |
+
- **setuptools==59.5.0**: Python 패키지 배포 및 설치를 위한 라이브러리.
|
178 |
+
- **scikit-image**: 이미지 처리 및 분석을 위한 라이브러리.
|
179 |
+
- **tabulate==0.9.0**: 표 형태로 데이터를 출력하는 라이브러리.
|
180 |
+
- **thop==0.1.1.post2209072238**: PyTorch 모델의 FLOP 수를 계산하는 도구.
|
181 |
+
- **timm==0.6.13**: 다양한 최신 이미지 분류 모델을 제공하는 라이브러리.
|
182 |
+
- **torch==2.0.0**: PyTorch 딥러닝 프레임워크.
|
183 |
+
- **torchvision==0.15.1**: 컴퓨터 비전 작업을 위한 PyTorch 확장 라이브러리.
|
184 |
+
- **tqdm==4.65.0**: 진행 상황을 시각적으로 표시하는 라이브러리.
|
185 |
+
- **pyautogui**: GUI 자동화를 위한 라이브러리.
|
186 |
|
187 |
+
### 모델 실행 단계:
|
188 |
|
189 |
### ✅ Prompt generating
|
190 |
```ruby
|
191 |
+
→ If you want to focus only on the final layers (where the model usually learns complex features), you can choose fewer DPAM layers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
```
|
193 |
|
194 |
+
### ✅ Test process
|
|
|
|
|
195 |
|
196 |
+
👍 **Load pre-trained and Fine tuned (Checkpoints) models**
|
197 |
+
1. Pre-trained mode (./pre-trained model/):
|
198 |
+
```ruby
|
199 |
+
→ Contains the pre-trained model (ViT-B, ViT-L,....)
|
200 |
+
→ Used as the starting point for training the CLIP model
|
201 |
+
→ Pre-trained model helps speed up and improve training by leveraging previously learned features
|
202 |
```
|
203 |
+
2. Fine-tuned models (./checkpoint/):
|
204 |
+
```ruby
|
205 |
+
→ "epoch_N.pth" files in this folder store the model's states during the fine-tuning process.
|
206 |
+
→ Each ".pth" file represents a version of the model fine-tuned from the pre-trained model
|
207 |
+
→ These checkpoints can be used to resume fine-tuning, evaluate the model at different stages, or select the best-performing version
|
|
|
|
|
208 |
```
|
209 |
|
210 |
|
|
|
211 |
# References
|
212 |
- AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection [[github](https://github.com/zqhang/AnomalyCLIP.git)]
|
213 |
|