Skip to content

Resnext translation #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions pytorch_vision_resnext.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
---
layout: hub_detail
background-class: hub-background
body-class: hub
title: ResNext
summary: Next generation ResNets, more efficient and accurate
category: researchers
image: resnext.png

author: Pytorch Team
tags: [vision, scriptable]
github-link: https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py
Expand All @@ -25,23 +18,20 @@ model = torch.hub.load('pytorch/vision:v0.10.0', 'resnext50_32x4d', pretrained=T
model.eval()
```

All pre-trained models expect input images normalized in the same way,
i.e. mini-batches of 3-channel RGB images of shape `(3 x H x W)`, where `H` and `W` are expected to be at least `224`.
The images have to be loaded in to a range of `[0, 1]` and then normalized using `mean = [0.485, 0.456, 0.406]`
and `std = [0.229, 0.224, 0.225]`.

Here's a sample execution.
모든 사전훈련된 모델은 입력 이미지가 같은 방식으로 정규화되었다고 가정합니다.
즉, 미니배치(mini-batch)의 3채널 RGB 이미지들은 `(3 x H x W)`의 shape을 가지며, `H`와 `W`는 최소 `224`이상이어야 하며, 각 이미지들은 `[0, 1]`의 범위에서 로드되어야 하며, 그 다음 `mean = [0.485, 0.456, 0.406]` 과 `std = [0.229, 0.224, 0.225]`를 이용해 정규화되어야 합니다.
아래 예시 코드가 있습니다.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 22번째 줄 문장이 원문에서 두 문장으로 된 것을 합친 것으로 보입니다. TRANSLATION_GUIDE에 의거하여 문장 단위는 가급적 유지할 수 있도록, 문장을 두 문장으로 나누는 편이 좋을 것 같습니다.
  2. 22번째 줄의 '각 이미지들은 [0, 1]의 범위에서 로드되어야 하며'의 경우, 기존 다른 문서의 PR에서 로드되어야 한다는 말의 의미를 설명하는 게 좋겠단 리뷰를 받아들여 해당 부분의 설명을 추가한 사례가 있습니다. 현재 문서에도 해당 내용을 추가해도 좋을 것 같다고 생각합니다.
    PyTorchKorea/hub-kr@df0adb6


```python
# Download an example image from the pytorch website
# 파이토치 웹 사이트에서 다운로드한 이미지 입니다.
import urllib
url, filename = ("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
try: urllib.URLopener().retrieve(url, filename)
except: urllib.request.urlretrieve(url, filename)
```

```python
# sample execution (requires torchvision)
# 예시 코드 (torchvision 필요)
from PIL import Image
from torchvision import transforms
input_image = Image.open(filename)
Expand All @@ -52,18 +42,18 @@ preprocess = transforms.Compose([
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
input_tensor = preprocess(input_image)
input_batch = input_tensor.unsqueeze(0) # create a mini-batch as expected by the model
input_batch = input_tensor.unsqueeze(0) # 모델에서 가정하는대로 미니배치 생성

# move the input and model to GPU for speed if available
# gpu를 사용할 수 있다면, 속도를 위해 입력과 모델을 gpu로 옮김
if torch.cuda.is_available():
input_batch = input_batch.to('cuda')
model.to('cuda')

with torch.no_grad():
output = model(input_batch)
# Tensor of shape 1000, with confidence scores over Imagenet's 1000 classes
# output은 shape가 [1000]인 Tensor 자료형이며, 이는 Imagenet 데이터셋의 각 클래스에 대한 모델의 확신도(confidence)를 나타냄.
print(output[0])
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
# output은 정규화되지 않았으므로, 확률화하기 위해 softmax 함수를 처리합니다.
probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
```
Expand Down