| | --- |
| | license: cc-by-nc-4.0 |
| | tags: |
| | - image-classification |
| | - pytorch |
| | - defect-detection |
| | - manufacturing |
| | - quality-control |
| | language: |
| | - ko |
| | datasets: |
| | - custom |
| | metrics: |
| | - accuracy |
| | library_name: pytorch |
| | pipeline_tag: image-classification |
| | --- |
| | |
| | # μμ₯곡μ λΆλν λΆλ₯ λͺ¨λΈ (Assembly Process Defect Classification) |
| |
|
| | μ΄ λͺ¨λΈμ μμ₯곡μ μμ λ°μνλ λ€μν λΆλ μ νμ λΆλ₯νκΈ° μν΄ ResNet50 μν€ν
μ²λ₯Ό κΈ°λ°μΌλ‘ νμΈνλλ λͺ¨λΈμ
λλ€. |
| |
|
| | ## λͺ¨λΈ μ 보 |
| |
|
| | - **μν€ν
μ²**: ResNet50 |
| | - **ν΄λμ€ μ**: 24κ° |
| | - **μ
λ ₯ ν¬κΈ°**: 224x224 RGB μ΄λ―Έμ§ |
| | - **λΆλ₯ μΉ΄ν
κ³ λ¦¬**: 12κ°μ§ λΆλ μ ν Γ 2κ°μ§ νμ§ μν (λΆλν/μν) |
| |
|
| | ## λΆλ₯ ν΄λμ€ |
| |
|
| | ### λΆλ μ νλ³ λΆλ₯ |
| | - **κ³ μ λΆλ**: λΆλν(0), μν(1) |
| | - **κ³ μ ν λΆλ**: λΆλν(2), μν(3) |
| | - **λ¨μ°¨**: λΆλν(4), μν(5) |
| | - **μ€ν¬λμΉ**: λΆλν(6), μν(7) |
| | - **μ€λ§ λΆλ**: λΆλν(8), μν(9) |
| | - **μ°κ³ λΆλ**: λΆλν(10), μν(11) |
| | - **μΈκ΄ μμ**: λΆλν(12), μν(13) |
| | - **μ 격 λΆλ**: λΆλν(14), μν(15) |
| | - **μ₯μ°© λΆλ**: λΆλν(16), μν(17) |
| | - **체결 λΆλ**: λΆλν(18), μν(19) |
| | - **ν€λ° λΆλ**: λΆλν(20), μν(21) |
| | - **ν λ³ν**: λΆλν(22), μν(23) |
| |
|
| | ## μ¬μ©λ² |
| |
|
| | ### λͺ¨λΈ λ‘λ λ° μΆλ‘ |
| |
|
| | ```python |
| | import torch |
| | from torchvision import models, transforms |
| | from PIL import Image |
| | |
| | # λͺ¨λΈ λ‘λ |
| | model = models.resnet50(num_classes=24) |
| | model.fc = torch.nn.Linear(model.fc.in_features, 24) |
| | model.load_state_dict(torch.load('pytorch_model.bin', map_location='cpu')) |
| | model.eval() |
| | |
| | # μ΄λ―Έμ§ μ μ²λ¦¬ |
| | transform = transforms.Compose([ |
| | transforms.Resize((224, 224)), |
| | transforms.ToTensor(), |
| | transforms.Normalize(mean=[0.485, 0.456, 0.406], |
| | std=[0.229, 0.224, 0.225]) |
| | ]) |
| | |
| | # μΆλ‘ |
| | img = Image.open('your_image.jpg').convert('RGB') |
| | input_tensor = transform(img).unsqueeze(0) |
| | |
| | with torch.no_grad(): |
| | outputs = model(input_tensor) |
| | predicted_class = torch.argmax(outputs, dim=1).item() |
| | |
| | # ν΄λμ€λͺ
λ§€ν |
| | class_names = { |
| | 0: 'κ³ μ λΆλ_λΆλν', 1: 'κ³ μ λΆλ_μν', |
| | 2: 'κ³ μ ν λΆλ_λΆλν', 3: 'κ³ μ ν λΆλ_μν', |
| | 4: 'λ¨μ°¨_λΆλν', 5: 'λ¨μ°¨_μν', |
| | 6: 'μ€ν¬λμΉ_λΆλν', 7: 'μ€ν¬λμΉ_μν', |
| | 8: 'μ€λ§ λΆλ_λΆλν', 9: 'μ€λ§ λΆλ_μν', |
| | 10: 'μ°κ³ λΆλ_λΆλν', 11: 'μ°κ³ λΆλ_μν', |
| | 12: 'μΈκ΄ μμ_λΆλν', 13: 'μΈκ΄ μμ_μν', |
| | 14: 'μ 격 λΆλ_λΆλν', 15: 'μ 격 λΆλ_μν', |
| | 16: 'μ₯μ°© λΆλ_λΆλν', 17: 'μ₯μ°© λΆλ_μν', |
| | 18: '체결 λΆλ_λΆλν', 19: '체결 λΆλ_μν', |
| | 20: 'ν€λ° λΆλ_λΆλν', 21: 'ν€λ° λΆλ_μν', |
| | 22: 'ν λ³ν_λΆλν', 23: 'ν λ³ν_μν' |
| | } |
| | |
| | print(f"μμΈ‘ κ²°κ³Ό: {class_names[predicted_class]}") |
| | ``` |
| |
|
| | ### νκΉ
νμ΄μ€ Transformers λΌμ΄λΈλ¬λ¦¬ μ¬μ© |
| |
|
| | ```python |
| | from transformers import AutoConfig |
| | import torch |
| | from torchvision import models |
| | |
| | # μ€μ λ‘λ |
| | config = AutoConfig.from_pretrained('your-username/defect-classification-resnet50') |
| | |
| | # λͺ¨λΈ λ‘λ |
| | model = models.resnet50(num_classes=config.num_classes) |
| | model.fc = torch.nn.Linear(model.fc.in_features, config.num_classes) |
| | model.load_state_dict(torch.hub.load_state_dict_from_url( |
| | 'https://huggingface.co/your-username/defect-classification-resnet50/resolve/main/pytorch_model.bin', |
| | map_location='cpu' |
| | )) |
| | ``` |
| |
|
| | ## λͺ¨λΈ μ±λ₯ |
| |
|
| | - **μ νλ**: 0.7509 |
| | - **κ²μ¦ λ°μ΄ν°μ
**: [λ°μ΄ν°μ
μ 보 μ
λ ₯] |
| |
|
| | ## μ νμ¬ν |
| |
|
| | - μ΄ λͺ¨λΈμ νΉμ μ μ‘° νκ²½μμ μμ§λ λ°μ΄ν°λ‘ νμ΅λμμΌλ―λ‘, λ€λ₯Έ νκ²½μμλ μ±λ₯μ΄ λ¬λΌμ§ μ μμ΅λλ€. |
| | - μ€μ μ΄μ νκ²½μμ μ¬μ©νκΈ° μ μ μΆ©λΆν ν
μ€νΈλ₯Ό κΆμ₯ν©λλ€. |
| |
|
| | ## λΌμ΄μ μ€ |
| |
|
| | CC BY-NC |
| |
|
| | ## μΈμ© |
| |
|
| | μ΄ λͺ¨λΈμ μ¬μ©νμ λ€λ©΄ λ€μκ³Ό κ°μ΄ μΈμ©ν΄μ£ΌμΈμ: |
| |
|
| | ``` |
| | @misc{vehicle-assembly-process-defect-detection-model, |
| | title={Assembly Process Defect Classification with ResNet50}, |
| | author={doyoon kwon}, |
| | year={2025}, |
| | url={https://huggingface.co/23smartfactory/vehicle-assembly-process-defect-detection-model} |
| | } |
| | ``` |