boostcampaitech3 / final-project-level3-cv-16

πŸ‘€ λ„ˆμ˜ μ•Œμ•½μ΄ 보여 πŸ’Š : μ•Œμ•½ 이미지 λΆ„λ₯˜ ν”„λ‘œμ νŠΈ
5 stars 6 forks source link

[ML][Enhancement] Image Classification #29

Closed yehyunsuh closed 2 years ago

yehyunsuh commented 2 years ago

What

Image Classification

Why

For use in our project

How

reference: #15 #25

yehyunsuh commented 2 years ago

type & shape classification

pill_type = ["μ•Œμ•½_μ›ν˜•",'μ•Œμ•½_μž₯λ°©ν˜•orνƒ€μ›ν˜•','μ•Œμ•½_기타','μ•Œμ•½_νŒ”κ°ν˜•','μ•Œμ•½_μ‚Όκ°ν˜•','μ•Œμ•½_μ‚¬κ°ν˜•','μ•Œμ•½_μ˜€κ°ν˜•','μ•Œμ•½_μœ‘κ°ν˜•','μ•Œμ•½_λ§ˆλ¦„λͺ¨ν˜•','캑슐_μž₯λ°©ν˜•orνƒ€μ›ν˜•','캑슐_기타']

color classification

pill_type = sorted(['투λͺ…', '연두, 투λͺ…', '초둝, 투λͺ…', 'νšŒμƒ‰', 'ν•˜μ–‘, 투λͺ…', 'κ°ˆμƒ‰orλΉ¨κ°•', 'λ…Έλž‘orμ£Όν™©', 'μ£Όν™©, 투λͺ…', 'ν•˜μ–‘, λ…Έλž‘', '뢄홍, 투λͺ…', 'κ°ˆμƒ‰, 투λͺ…', '보라', '연두or초둝', '보라, 투λͺ…', '청둝, 투λͺ…', 'ν•˜μ–‘, κ°ˆμƒ‰', '청둝', '뢄홍', 'ν•˜μ–‘, νŒŒλž‘', 'ν•˜μ–‘', 'λΉ¨κ°•, 투λͺ…', '남색', 'νŒŒλž‘, 투λͺ…', 'νŒŒλž‘', 'κ²€μ •', '자주', 'λ…Έλž‘, 투λͺ…']) 

tablet/capsule classification

pill_type = ['μ•Œμ•½','캑슐']

How to bring pretrained model

model = timm.create_model('resnet50', pretrained=True, num_classes=30)

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") 
model.to(device) 

PATH = ""
model.load_state_dict(torch.load(PATH, map_location=device))

If evaluation needed

with torch.no_grad():
    print("Calculating validation results...")
    model.eval()
    i, accuracy = 0, []
    for test in test_loader:
        inputs = test
        inputs = inputs.to(device)

        outs = model(inputs)
        preds = torch.argmax(outs, dim=-1)

        print(preds)   # result of the classification
yehyunsuh commented 2 years ago

Classification done. The train dataset will be changed to segmented data. Issue close.