{
  "fetched_at": "2026-10-24T15:27:25Z",
  "source_url": "https://www.kaggle.com/competitions/2021-ml-tp2/data",
  "pages": [
    {
      "name": "data-description",
      "content": "### MVTEC AD\n이번 텀프로젝트에서는 산업 분야 중 제조업 분야에서의 비지도 학습 기반 이상 검출 데이터 셋 MVTEC AD[1]([home](https://www.mvtec.com/company/research/datasets/mvtec-ad), [pdf](https://www.mvtec.com/fileadmin/Redaktion/mvtec.com/company/research/datasets/mvtec_ad.pdf))를 이용하여 이상 상황 검출을 풀어보고자합니다.  해당 데이터 셋은 아래와 같이 총 15가지의 클래스를 가진 영상을 제공하며,  각 클래스에 해당하는 제조업에서 발생할 수 있는 이상 상황(품질 불량)을 인위적으로 생성하였으며, 영상에서의 제조품이 명확하도록 설계된 조명과 배경과 영상 가운데에 위치하도록 촬영되었습니다. 각 클래스의 예제 영상들은 Overview-Description Fig 1에서 확인 할 수 있습니다.\n데이터 셋 구성은 [MVTecAD_colab](https://colab.research.google.com/drive/1pdgvoPs3KDLq6pV9oLxkXDh6waEp76HT?usp=sharing)에서도 확인 할 수 있습니다.\n<br>\n\n### 데이터 구성\n데이터 셋의 영상 갯수는 아래와 같습니다.\n\ntrain : 3629장 <br>\ntest : 467(good) + 1258(fault case) <br>\nall : 5354장 <br>\n\n데이터 파일의 구조는 아래와 같습니다.\n\n{ClassName} <br>\n|--ground_truth: fault case 이상 부분에 대한 Segmentation mask <br>\n|--train <br>\n|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|---정상 케이스에 대한 영상 <br>\n|__test <br>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--- fault&normal case. 각 클래스에 해당하는 case는 아래의 정보 참고. <br>\n\n\n % ClassName : [각 클래스에 해당하는 이상 케이스(fault case)와 정상 케이스('good')]\n\n- metal_nut : ['good', 'flip', 'bent', 'color', 'scratch']\n- toothbrush : ['good', 'defective']\n- leather : ['poke', 'good', 'fold', 'glue', 'cut', 'color']\n - cable : ['combined', 'cut_outer_insulation', 'missing_wire', 'missing_cable', 'poke_insulation', 'good', 'bent_wire', 'cable_swap', 'cut_inner_insulation']\n- wood : ['good', 'liquid', 'hole', 'scratch', 'combined', 'color']\n- transistor : ['damaged_case', 'misplaced', 'good', 'bent_lead', 'cut_lead']\n- zipper : ['split_teeth', 'combined', 'good', 'broken_teeth', 'squeezed_teeth', 'fabric_interior', 'fabric_border', 'rough']\n- pill : ['faulty_imprint', 'combined', 'contamination', 'pill_type', 'crack', 'good', 'scratch', 'color']\n- bottle : ['good', 'broken_small', 'broken_large', 'contamination']\n- capsule : ['poke', 'squeeze', 'faulty_imprint', 'scratch', 'good', 'crack']\n- carpet : ['color', 'thread', 'good', 'metal_contamination', 'hole', 'cut']\n- grid : ['thread', 'bent', 'glue', 'broken', 'good', 'metal_contamination']\n- hazelnut : ['hole', 'cut', 'print', 'good', 'crack']\n- screw : ['scratch_neck', 'good', 'manipulated_front', 'scratch_head', 'thread_side', 'thread_top']\n- tile : ['rough', 'good', 'oil', 'crack', 'glue_strip', 'gray_stroke']",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Description",
      "content": "# 과목 정보\n- 세종대학교 지능기전공학부 기계학습 (최유경 교수)\n\n---\n\n# 프로젝트 방향성 이해하기\n## 프로젝트의 목적\n- 본 프로젝트를 통해 2D 영상 데이터 내 이상 발생 여부(Anomaly Detection)를 판단할 수 있다. \n\n## 프로젝트 주의사항\n- 성능향상을 위해 인공신경망 방법은 사용할 수 없다.\n\n\n## 프로젝트 시작하기\n- (1) 프로젝트 메뉴얼을 자세하게 읽는다\n- (2) 스켈레톤 코드(Notebooks)를 복사한다. <== 반드시!\n- (3) 스켈레톤 코드 내 [Empty Module] 을 구현한다. <== 기존 스켈레톤 코드는 수정하지 않는다\n- (4) 결과 파일(csv)을 리더보드에 제출한다.\n- (5) 베이스라인을 넘지 못했다면, 프로젝트 메뉴얼과 스켈레톤 코드의 주석을 천천히 다시 읽어가면서 디버깅 한다.\n\n\n---\n\n# [프로젝트-4] 2D 영상 데이터 다루기 - 산업현장의 이상 상황 검출하기\n- 이상 상황 검출이란, 데이터에서 예상과는 다른 패턴을 보이는 개체 또는 자료를 찾는 것을 말합니다.  다양한 분야에서 사용되어지며, 각 분야 별 사용 예시는 아래와 같습니다.\n  -  사이버 보안. e.g. 비정상적인 트래픽 패턴을 감지\n  -  의학 분야. e.g. MRI 이미지로부터의 악성 종양 검출\n  -  금융 분야. e.g. 신용카드 거래 내역의 이상 검출을 통한 분실 및 도난 감지\n  -  행동 패턴 분야. e.g. CCTV를 통한 이상 패턴 감지를 통한 사고 방지\n  -  산업 분야. e.g.  생산된 제품의 품질 검사   <br>\n- 이상 상황은 위의 예시와 같이 드물게 나타나며 특정하기 힘든 형태로 나타나는 경우가 많습니다. 이런 특성상 특정 분포로 정의하기 힘들어, 정상 데이터와 다른 분포를 가진 데이터를 이상 상황이라고 칭합니다. 혹은 다른 관점으로는 기존 데이터 분포와 다른 새로운 분포를 가진 데이터를 찾는다고 하여 novelty detection라고도 불리기도 합니다. 이처럼 특정 분포를 정의하기 힘든 특성상  이상상황에 대한 데이터 셋을 구축하기 매우 힘듭니다. 이러한 사유로 대부분의 이상상황 검출들은 이상상황에 대한 데이터와 라벨이 필요한 지도학습보다는 라벨이 불필요한 비지도 학습 혹은 준 비지도 학습을 기반으로 문제를 해결합니다. \n-  이번 텀프로젝트에서는 다양한 분야 중 산업현장의 이상 상황 검출 문제를 다룰 예정입니다. 해당 문제는 MVTec AD 데이터 셋을 이용하여 비지도 학습 기반의 이상 상황 검출을 구현합니다. 비지도 학습 기반 검출기는 수업에서 다룬 차원 축소 알고리즘 PCA(Principal Compoent Analysis)와  분류기인 SVM(Support-Vector Machine)류의 모델 One-class SVM을 다뤄볼 예정 입니다.\n\n___\n\n## 프로젝트에서 사용되는 Raw 데이터 셋\n- 이번  텀프로젝트에서는 산업 분야 중 제조업 분야에서의 이상 상황 검출 데이터 셋 MVTecAD(1)( [home](https://www.mvtec.com/company/research/datasets/mvtec-ad), [pdf](https://www.mvtec.com/fileadmin/Redaktion/mvtec.com/company/research/datasets/mvtec_ad.pdf) )를 이용하여 이상 상황 검출을 풀어보고자합니다.  해당 데이터 셋은 아래와 같이 총 15가지의 클래스를 가진 영상을 제공하며,  각 클래스에 해당하는 제조업에서 발생할 수 있는 이상 상황(품질 불량)을 인위적으로 생성하였으며, 영상에서의 제조품이 명확하도록 설계된 조명과 배경과 영상 가운데에 위치하도록 촬영되었습니다. 각 클래스의 예제 영상들은 그림1(Fig.1)에서 확인 할 수 있습니다. \n- 해당 데이터 셋은 정상 상황의 영상 데이터(train)로 학습된 모델로부터 정상 상황과 이상 상황 영상 데이터(test)의 정상/이상을 분류하는 것이 목표입니다. 정상/이상 구분 시 영상과 픽셀 레벨에서의 분류를 진행합니다. 하지만 이번 텀프로젝트에서는 영상 레벨에서의 정상/이상에 대한 분류를 통해 이상 상황을 검출하도록 하겠습니다.\n\n++ 데이터 셋의 train/test와 각 클래스별 영상들은 [MVTecAD_colab](https://colab.research.google.com/drive/1pdgvoPs3KDLq6pV9oLxkXDh6waEp76HT?usp=sharing)에서 확인 할 수 있습니다.\n++ 이번 텀 프로젝트에서는 전체 데이터 셋 중 100개 이하의 영상을 가진 \"toothbrush\" 클래스를 제외한 [14가지] 클래스를 이용합니다.\n\n```python\n# 클래스 명 : [각 클래스에 해당하는 이상 케이스와 정상 케이스('good')]\nmetal_nut : ['good', 'flip', 'bent', 'color', 'scratch']\ntoothbrush : ['good', 'defective'] -> 해당 텀프로젝트에서는 제거한 상태로 제공.\nleather : ['poke', 'good', 'fold', 'glue', 'cut', 'color']\ncable : ['combined', 'cut_outer_insulation', 'missing_wire', 'missing_cable', 'poke_insulation', 'good', 'bent_wire', 'cable_swap', 'cut_inner_insulation']\nwood : ['good', 'liquid', 'hole', 'scratch', 'combined', 'color']\ntransistor : ['damaged_case', 'misplaced', 'good', 'bent_lead', 'cut_lead']\nzipper : ['split_teeth', 'combined', 'good', 'broken_teeth', 'squeezed_teeth', 'fabric_interior', 'fabric_border', 'rough']\npill : ['faulty_imprint', 'combined', 'contamination', 'pill_type', 'crack', 'good', 'scratch', 'color']\nbottle : ['good', 'broken_small', 'broken_large', 'contamination']\ncapsule : ['poke', 'squeeze', 'faulty_imprint', 'scratch', 'good', 'crack']\ncarpet : ['color', 'thread', 'good', 'metal_contamination', 'hole', 'cut']\ngrid : ['thread', 'bent', 'glue', 'broken', 'good', 'metal_contamination']\nhazelnut : ['hole', 'cut', 'print', 'good', 'crack']\nscrew : ['scratch_neck', 'good', 'manipulated_front', 'scratch_head', 'thread_side', 'thread_top']\ntile : ['rough', 'good', 'oil', 'crack', 'glue_strip', 'gray_stroke']\n```\n\n<p align=\"center\">\n  <img width=\"460\" height=\"300\" src=\"https://github.com/xown3197/TIL/blob/master/mvtecad.PNG?raw=true\">\n  <figcaption><br>Fig 1. MVTec AD 의 예제 영상. 상단의 다섯 개의 클래스는 textures, 이하 열 개의 클래스는 object category에 해당한다. 각 단락의 1열은 정상 상황, 2열은 이상 상황 3열은 이상 상황을 클로즈 업에 해당한다. 출처 [1]\n</p>\n\n## 데이터 셋 가공\n- 데이터 셋의 영상 갯수는 아래와 같습니다.\n  - train : 3629장 -> 정상 상황에 해당하는 영상만 존재\n  - test : 467(good) + 1258(fault case) -> 정상 상황에서의 영상(good)과 이상 상황에서의 영상(failt case)로 구성\n  - all : 5354장 \n- 데이터 파일의 구조는 아래와 같습니다.\n{ClassName} Original dataset과 동일\n|--val.csv : col1 : ID. test 영상 파일명, col2 : label. good:1, fault:-1\n|--train\n|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|---good\n|__test\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--- good&fault case\n\n## 이상 상황 검출(Anomaly Detection)\n-  이번 텀프로젝트에서는 이상 상황 검출을 위한 평가 방법 중 하나의 클래스에서 이상치를 찾는 것을 목적으로한 One-classification 방법을 이용하여 이상 상황을 평가하도록 합니다. \n  - One-classification을 간단하게 설명하면 각 클래스 별 학습과 평가를 별도로 진행합니다. \n  - 즉, MVTecAD의 14가지 클래스 별 추론과 평가를 진행합니다.  \n  - 사용되는 평가 메트릭은 ROC를 사용합니다.\n- 이번 텀프에서는 영상 기반의 이상 상황 검출을 적용되며 크게 두가지로 분류되어집니다.\n  - Reconstruction based anomaly detection\n     - 정상 영상으로부터 정상적 특성을 잘표현하는 feature를 추출하는 encoder와\n     - 추출된 feature를 원본 영상과 유사하게 복원하는 Decoder로 구성\n     - 정상적인 데이터로 학습된 encoder-decoder로 이상 영상을 복원 시, 정상 영상과 유사하도록 복원 영상을 생성될 것이라고 가정을 함.\n     - 입력 영상 I과 encoder-decoder로 복원된 영상 I'의 차이를 정상/이상에 대한 분류 점수로 사용.\n     - 이상 영상과 복원 영상(이상)의 차이는 크고, 정상 영상과 복원 영상(정상)의 차이는 작음\n  - Embedding feature based anomaly detection\n     - 정상 영상의 정상적인 특성을 학습한 feature extrator를 이용하여  정상/이상 영상의 feature를 추출\n     - 정상 feature의 분포 경계를 잘 배우도록 모델을 학습\n     - 정상 feature의 분포 경계에 벗어나는 경우 이상치로 검출\n- 텀프로젝트에서는 PCA를 활용하여 위의 두 가지 방법을 적용하는 것이 목표입니다. \n\n## 구현 가이드라인 \n\n### 스켈레톤 코드\n- https://www.kaggle.com/xown3197/skeleton-code\n\n### [Empty Module #1] Reconstruction based anomaly detection\n- 이번 텀프로젝트에서의 Reconstruction based anomaly detection은 PCA로 이뤄진 encoder와 decoder를 이용합니다. \n- 파이프라인은 아래와 같습니다.\n  - (1) PCA를 이용하여 정상 영상으로 구성된 train data의 주성분을 추출하여 train data를  feature f로 n_component 크기가 되도록 차원 축소(feature 추출)\n  - (2) 정상/이상 영상이 포함된 test data에 1에서 적용된 PCA로 featrue f_test 추출\n  - (3) featrue f_test를 복원\n  - (4) 원본 영상과 복원 영상의 차를 구하여 socre를 추출\n\n```\n# -------------------------------------\n# [Empty Module #1] Reconstruction based anomaly detection\n# -------------------------------------\n# \n# ------------------------------------------------------------\n# 구현 가이드라인 \n# ------------------------------------------------------------\n# [1] train.imgs와 val.imgs 정규화.\n# [2] PCA 초기화 및 train imgs를 학습\n# Baseline : PCA(n_components=n_components), random_state=777\n# [3] val imgs를 transform.\n# [4] [3]로 얻은 val_pca를 inverse_transform을 통해 복원. scaler의 \n# inverse_transform을 진행 후, (num_data_imgs, img_width, img_height)로 reshape.\n# [5] Reconstruction_error = Original imgs - Reconstruction imgs\n# Original imgs : reshape (num_data_imgs, img_width, img_height)를 해야합니다.\n# ------------------------------------------------------------\n```\n\n### [Empty Module #2] Embedding feature based anomaly detection\n- 이번 텀프로젝트에서의 embedding feature based anomaly detection은 randomized PCA와 one-class SVM을 이용합니다.\n- 파이프라인은 아래와 같습니다.\n  - (1) Randomized PCA를 이용하여 정상 영상의 feature f를 추출\n  - (2)  one-class SVM을 이용하여 f의 support vector를 학습합니다.\n  - (3) 1에서 사용된 randomized PCA 이상/정상 영상의 feature f_ts를 추출니다.\n  - (4) one-class SVM로 f_ts가 정상 분포 경계에 포함 여부로 정상/이상을 분류합니다.\n\n```\n# -------------------------------------\n# [Empty Module #2]\n# -------------------------------------\n# ------------------------------------------------------------\n# 구현 가이드라인 \n# ------------------------------------------------------------\n# Empty Module\n# [0] classification module과 pca 모델 초기화\n#  사용된 PCA. e.g. PCA, RandomizePCA, KernelPCA...\n# Baseline : sklearn.svm.OneClassSVM, kernel=\"rbf\", gamma=0.001, nu=0.01\n# Baseline : PCA(n_components=n_components), random_state=777\n# RandomizePCA ~(svd_solver='randomized') 사용시, whiten=True로 사용.\n# [1] train.imgs와 val.imgs 정규화.\n# [2] PCA 초기화와 정규화된 train.imgs를 학습 후, 정규화된 train.imgs, val imgs를 transform.\n# [3] OneClassSVM을 이용하여 차원 축소된 train 학습 후 val data 추론. \n# hint. OneClassSVM.predict, OneClassSVM.score_samples 사용.\n# [4] test.imgs에 [1]~[3]과 동일한 과정을 적용. 단, 추론 시 score에 대해서만 계산\n# ------------------------------------------------------------\n```\n\n### 리더보드 베이스라인 정보\n- Baseline_1 / PCA-OC-SVM / 0.54373\n- Baseline_2 / RandomizedPCA-OC-SVM / 0.67165 \n\n## 참고 자료\n- [1] Paul Bergmann, Michael Fauser, David Sattlegger, Carsten Steger: MVTec AD – A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection;\n  in: IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2019\n\n----\n\n## 코멘트\n- 본 프로젝트는 세종대학교 김태주 조교에 의해 작성되었습니다. (tjkim@rcv.sejong.ac.kr)\n- 프로젝트와 관련된 문의는 슬랙을 이용해 주세요.",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Evaluation",
      "content": "Submissions are evaluated on area under the ROC curve between the predicted probability and the observed target.",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "rules",
      "content": "This is a page where you can include rules that participants must accept before joining. You may wish to include rules like:\n\n - Don't cheat!\n - Apply yourself!\n - Have fun!",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    }
  ]
}