Skip to content

Latest commit

ย 

History

History
71 lines (60 loc) ยท 2.35 KB

nicolalandro_ntsnet-cub200_ntsnet.md

File metadata and controls

71 lines (60 loc) ยท 2.35 KB
layout background-class body-class category title summary image author tags github-link github-id featured_image_1 featured_image_2 accelerator demo-model-link
hub_detail
hub-background
hub
researchers
ntsnet
classify birds using this fine-grained image classifier
Cub200Dataset.png
Moreno Caraffini and Nicola Landro
vision
nicolalandro/ntsnet-cub200
nts-net.png
no-image
cuda-optional
import torch
model = torch.hub.load('nicolalandro/ntsnet-cub200', 'ntsnet', pretrained=True,
                       **{'topN': 6, 'device':'cpu', 'num_classes': 200})

์‚ฌ์šฉ ์˜ˆ์ œ

from torchvision import transforms
import torch
import urllib
from PIL import Image

transform_test = transforms.Compose([
    transforms.Resize((600, 600), Image.BILINEAR),
    transforms.CenterCrop((448, 448)),
    # transforms.RandomHorizontalFlip(),  # only if train
    transforms.ToTensor(),
    transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
])


model = torch.hub.load('nicolalandro/ntsnet-cub200', 'ntsnet', pretrained=True, **{'topN': 6, 'device':'cpu', 'num_classes': 200})
model.eval()

url = 'https://raw.githubusercontent.com/nicolalandro/ntsnet-cub200/master/images/nts-net.png'
img = Image.open(urllib.request.urlopen(url))
scaled_img = transform_test(img)
torch_images = scaled_img.unsqueeze(0)

with torch.no_grad():
    top_n_coordinates, concat_out, raw_logits, concat_logits, part_logits, top_n_index, top_n_prob = model(torch_images)

    _, predict = torch.max(concat_logits, 1)
    pred_id = predict.item()
    print('bird class:', model.bird_classes[pred_id])

๋ชจ๋ธ ์„ค๋ช…

์ด ๋ชจ๋ธ์€ ์„ธ๋ถ„ํ™”๋œ ์กฐ๋ฅ˜ ๋ฐ์ดํ„ฐ์…‹์ธ CUB200 2011 ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ ์‚ฌ์ „ ํ•™์Šต๋œ nts-net์ž…๋‹ˆ๋‹ค.

์ฐธ์กฐ

link - ์—ฌ๊ธฐ์—์„œ ์ „์ฒด ๋‚ด์šฉ์„ ์ฝ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@INPROCEEDINGS{Gallo:2019:IVCNZ,
  author={Nawaz, Shah and Calefati, Alessandro and Caraffini, Moreno and Landro, Nicola and Gallo, Ignazio},
  booktitle={2019 International Conference on Image and Vision Computing New Zealand (IVCNZ 2019)},
  title={Are These Birds Similar: Learning Branched Networks for Fine-grained Representations},
  year={2019},
  month={Dec},
}