| layout | hub_detail | |
|---|---|---|
| background-class | hub-background | |
| body-class | hub | |
| title | ResNet50 | |
| summary | ResNet50 model trained with mixed precision using Tensor Cores. | |
| category | researchers | |
| image | nvidia_logo.png | |
| author | NVIDIA | |
| tags |
|
|
| github-link | https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/Classification/ConvNets/resnet50v1.5 | |
| github-id | NVIDIA/DeepLearningExamples | |
| featured_image_1 | classification.jpg | |
| featured_image_2 | no-image | |
| accelerator | cuda | |
| order | 10 | |
| demo-model-link | https://huggingface.co/spaces/pytorch/ResNet50 |
ResNet50 v1.5λͺ¨λΈμ original ResNet50 v1 modelμ μμ λ λ²μ μ λλ€.
v1κ³Ό v1.5μ μ°¨μ΄μ μ λ€μ΄μνλ§μ΄ νμν λ³λͺ© λΈλ‘μμ v1μ 첫 λ²μ§Έ 1x1 컨볼루μ μμ μ€νΈλΌμ΄λ = 2λ₯Ό κ°λ λ°λ©΄ v1.5λ 3x3 컨볼루μ μμ μ€νΈλΌμ΄λ = 2λ₯Ό κ°λλ€λ κ²μ λλ€.
μ΄λ¬ν μ°¨μ΄λ ResNet50 v1.5λ₯Ό v1λ³΄λ€ μ‘°κΈ λ μ ννκ² λ§λ€μ§λ§(~0.5% top1) μ½κ°μ μ±λ₯μ μΈ λ¨μ (~5% imgs/sec)μ΄ μμ΅λλ€.
λͺ¨λΈμ Delving deep into rectifiers: Surpassing human-level performance on ImageNet classificationμ μ€λͺ λ λλ‘ μ΄κΈ°νλ©λλ€.
μ΄ λͺ¨λΈμ Volta, Turing λ° NVIDIA Ampere GPU μν€ν μ²μ Tensor μ½μ΄λ₯Ό μ¬μ©νμ¬ νΌν© μ λ°λ(mixed precision)λ‘ νμ΅λ©λλ€. λ°λΌμ μ°κ΅¬μλ€μ νΌν© μ λ° κ΅μ‘μ μ΄μ μ κ²½ννλ©΄μ Tensor Core μμ΄ νμ΅νλ κ²λ³΄λ€ 2λ°° μ΄μ λΉ λ₯Έ κ²°κ³Όλ₯Ό μ»μ μ μμ΅λλ€. μ΄ λͺ¨λΈμ μκ°μ΄ μ§λ¨μ λ°λΌ μΌκ΄λ μ νμ±κ³Ό μ±λ₯μ 보μ₯νκΈ° μν΄ κ° NGC μλ³ μ»¨ν μ΄λ 릴리μ€μ λν΄ ν μ€νΈλ©λλ€.
ResNet50 v1.5 λͺ¨λΈμ TorchScript, ONNX Runtime λλ TensorRTλ₯Ό μ€ν λ°±μλλ‘ μ¬μ©νμ¬ NVIDIA Triton Inference Serverμμ μΆλ‘ μ μν΄ λ°°μΉλ μ μμ΅λλ€. μμΈν λ΄μ©μ NGCλ₯Ό νμΈνμμμ€.
μλ μμ μμλ μ¬μ νλ ¨λ ResNet50 v1.5 λͺ¨λΈμ μ¬μ©νμ¬ μ΄λ―Έμ§μ λν μΆλ‘ μ μν νκ³ κ²°κ³Όλ₯Ό μ μν κ²μ λλ€.
μμ λ₯Ό μ€ννλ €λ©΄ λͺ κ°μ§ μΆκ° νμ΄μ¬ ν¨ν€μ§κ° μ€μΉλμ΄ μμ΄μΌ ν©λλ€. μ΄λ μ΄λ―Έμ§λ₯Ό μ μ²λ¦¬νκ³ μκ°ννλ λ° νμν©λλ€.
!pip install validators matplotlibimport torch
from PIL import Image
import torchvision.transforms as transforms
import numpy as np
import json
import requests
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
print(f'Using {device} for inference')IMAGENET λ°μ΄ν°μ μμ μ¬μ νλ ¨λ λͺ¨λΈμ λ‘λν©λλ€.
resnet50 = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_resnet50', pretrained=True)
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_convnets_processing_utils')
resnet50.eval().to(device)μν μ λ ₯ λ°μ΄ν°λ₯Ό μ€λΉν©λλ€.
uris = [
'http://images.cocodataset.org/test-stuff2017/000000024309.jpg',
'http://images.cocodataset.org/test-stuff2017/000000028117.jpg',
'http://images.cocodataset.org/test-stuff2017/000000006149.jpg',
'http://images.cocodataset.org/test-stuff2017/000000004954.jpg',
]
batch = torch.cat(
[utils.prepare_input_from_uri(uri) for uri in uris]
).to(device)μΆλ‘ μ μ€νν©λλ€. pick_n_best(predictions=output, n=topN) helper ν¨μλ₯Ό μ¬μ©νμ¬ λͺ¨λΈμ λ°λΌ κ°μ₯ κ°λ₯μ±μ΄ λμ κ°μ€μ Nκ° μ νν©λλ€.
with torch.no_grad():
output = torch.nn.functional.softmax(resnet50(batch), dim=1)
results = utils.pick_n_best(predictions=output, n=5)κ²°κ³Όλ₯Ό νμν©λλ€.
for uri, result in zip(uris, results):
img = Image.open(requests.get(uri, stream=True).raw)
img.thumbnail((256,256), Image.ANTIALIAS)
plt.imshow(img)
plt.show()
print(result)λͺ¨λΈ μ λ ₯ λ° μΆλ ₯, νμ΅ λ°©λ², μΆλ‘ λ° μ±λ₯ λ±μ λν λ μμΈν μ 보λ github λ° and/or NGCμμ λ³Ό μ μμ΅λλ€.