Skip to content

Modify docs: Translate mobilenet_v2 Eng to Kor #15

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
39 changes: 19 additions & 20 deletions pytorch_vision_mobilenet_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ layout: hub_detail
background-class: hub-background
body-class: hub
title: MobileNet v2
summary: Efficient networks optimized for speed and memory, with residual blocks
summary: residual block을 통해 속도와 메모리에 최적화된 효율적인 네트워크
category: researchers
image: mobilenet_v2_1.png
author: Pytorch Team
author: Pytorch
tags: [vision, scriptable]
github-link: https://github.com/pytorch/vision/blob/main/torchvision/models/mobilenet.py
github-id: pytorch/vision
Expand All @@ -23,23 +23,22 @@ model = torch.hub.load('pytorch/vision:v0.10.0', 'mobilenet_v2', pretrained=True
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]`.
모든 사전 훈련된 모델들은 입력 이미지가 동일한 방식으로 정규화되었다고 상정합니다.
즉, 미니 배치(mini-batch)의 3-채널 RGB 이미지들은 `(3 x H x W)`의 형태를 가지며, 해당 `H`와 `W`는 최소 `224` 이상이어야 합니다.
각 이미지는 `[0, 1]`의 범위 내에서 로드되어야 하며, `mean = [0.485, 0.456, 0.406]` 과 `std = [0.229, 0.224, 0.225]`을 이용해 정규화되어야 합니다.
Comment on lines -26 to +28
Copy link

Choose a reason for hiding this comment

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

PyTorchKorea/hub-kr@df0adb6

기존에 VGG_NET의 번역 PR에서 해당 부분과 똑같은 문장을 번역했었습니다.
번역이 조금 다르지만 번역 상 문제가 있다곤 생각되지 않으며, mindongjun 님께서 참고 후 수정이 필요하면 수정하시면 될 것 같습니다.
다만, 해당 PR 리뷰에서 '각 이미지는 [0,1] 범위 내에서 로드되어야 하며' 부분에 대해, 로드되어야 한다는 말의 의미를 추가해줬으면 좋겠다고 하였고 실제 이를 반영하여 최종 Merge가 되었습니다. 따라서 통일성을 위해 PR 해주신 문서에도 해당 내용을 추가해 주시면 좋을 것 같다고 생각합니다.


Here's a sample execution.
다음은 실행 예제 입니다.

```python
# Download an example image from the pytorch website
# pytorch 웹사이트에서 예제 이미지 다운로드
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 @@ -50,46 +49,46 @@ 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로 이동
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은 1000개의 Tensor 형태이며, 이는 Imagenet 데이터 셋의 1000개 클래스에 대한 신뢰도 점수를 나타내는 결과
Copy link

Choose a reason for hiding this comment

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

https://github.com/PyTorchKorea/tutorials-kr/blob/master/TRANSLATION_GUIDE.md

TRANSLATION_GUIDE.md에 따라, 'output'은 '출력'으로 번역하기를 권장합니다.

print(output[0])
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
# output 결과는 정규화되지 않은 결과. 확률을 얻기 위해선 softmax를 거쳐야 함.
Copy link

Choose a reason for hiding this comment

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

https://github.com/PyTorchKorea/tutorials-kr/blob/master/TRANSLATION_GUIDE.md

  1. TRANSLATION_GUIDE.md에 따라, 'output'은 '출력'으로 번역하는 게 좋다고 생각합니다.
  2. 용어집에는 없지만, 'softmax'를 '소프트맥스'로 적어도 좋을 것 같습니다.(팀 문서에 용어집 추가할 내용으로 적어뒀습니다.)
  3. softmax를 거쳐야 함 이란 말이 초보자들에게 이해가 되지 않을 수 있다고 생각합니다. 의미를 좀 더 명확하게 '소프트맥스 함수를 취해줘야 함.' 이라 하면 좋을 것 같은데, 이 부분 생각이 궁금합니다.

probabilities = torch.nn.functional.softmax(output[0], dim=0)
print(probabilities)
```

```
# Download ImageNet labels
# ImageNet 라벨 다운로드
!wget https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt
```

```
# Read the categories
# 카테고리 읽어들이기
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# Show top categories per image
# 이미지 별 상위 카테고리 표시
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
```

### Model Description
### 모델 설명

The MobileNet v2 architecture is based on an inverted residual structure where the input and output of the residual block are thin bottleneck layers opposite to traditional residual models which use expanded representations in the input. MobileNet v2 uses lightweight depthwise convolutions to filter features in the intermediate expansion layer. Additionally, non-linearities in the narrow layers were removed in order to maintain representational power.
MobileNet v2 아키텍처는 residual block의 입력 및 출력이 입력단에서 확장 표현을 사용하는 기존의 residual 모델과 반대되는 얇은 병목 계층인 반전된 residual 구조를 기반으로 합니다. MobileNet v2는 경량화된 depthwise convolutions를 사용하여 중간 확장 계층의 특징 들을 필터링합니다. 또한, 표현력 유지를 위해 좁은 계층의 비선형성은 제거되었습니다.
Comment on lines -86 to +85
Copy link

Choose a reason for hiding this comment

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

'residual block의 입력 및 출력이 입력단에서 확장 표현을 사용하는 기존의 residual 모델과 반대되는 얇은 병목 계층인 반전된 residual 구조를 기반으로 합니다.' 부분이 문장이 길고 수식어가 많아 읽는 입장에서 잘못 이해할 수 있을 것 같습니다. '입력단에서 확장 표현을 사용하는 기존의 residual 모델과 반대되게, residual block의 입력 및 출력이 얇은 병목 계층인 반전된 residual 구조를 기반으로 합니다.' 로 문장 내 순서를 바꾸면 의미가 좀 더 명확할 것 같습니다.


| Model structure | Top-1 error | Top-5 error |
| 모델 구조 | Top-1 오류 | Top-5 오류 |
| --------------- | ----------- | ----------- |
| mobilenet_v2 | 28.12 | 9.71 |


### References
### 참고문헌

- [MobileNetV2: Inverted Residuals and Linear Bottlenecks](https://arxiv.org/abs/1801.04381)