diff --git a/pytorch_vision_ghostnet.md b/pytorch_vision_ghostnet.md index 693bd5b..06223f6 100644 --- a/pytorch_vision_ghostnet.md +++ b/pytorch_vision_ghostnet.md @@ -23,15 +23,15 @@ model = torch.hub.load('huawei-noah/ghostnet', 'ghostnet_1x', 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]`. +모든 사전 학습된 모델들은 입력 이미지가 동일한 방식으로 정규화 되는 것을 요구합니다. +다시 말해 `H`와 `W`가 적어도 `224`이고, `(3 x H x W)`의 shape를 가지는 3채널 RGB 이미지들의 미니배치를 말합니다. +이 이미지들은 `[0, 1]`의 범위로 로드되어야 하고, `mean = [0.485, 0.456, 0.406]` +과 `std = [0.229, 0.224, 0.225]`를 사용하여 정규화되어야 합니다. -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) @@ -39,7 +39,7 @@ 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) @@ -50,51 +50,53 @@ 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 +# 연산속도를 위해 input과 모델을 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 +# ImageNet 1000개의 클래스의 신뢰점수를 포함하는 (1000,) 의 텐서를 return 합니다. print(output[0]) -# The output has unnormalized scores. To get probabilities, you can run a softmax on it. +# output은 정규화되지 않은 신뢰 점수로 얻어집니다. 확률을 얻기 위해 소프트맥스를 사용할 수 있습니다. 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 GhostNet architecture is based on an Ghost module structure which generate more features from cheap operations. Based on a set of intrinsic feature maps, a series of cheap operations are applied to generate many ghost feature maps that could fully reveal information underlying intrinsic features. Experiments conducted on benchmarks demonstrate that the superiority of GhostNet in terms of speed and accuracy tradeoff. +고스트넷 아키텍처는 다양한 특징 맵을 효율적인 연산으로 생성하는 고스트 모듈 구조로 이루어집니다. +합성곱 신경망에서의 학습 과정에서 추론에 중요한 중복되는 고유 특징맵(고스트 맵)들이 다수 생성되는 현상에 기반하여 설계 되었습니다. 고스트넷에서는 더 효율적인 연산으로 고스트 맵들을 생성합니다. +벤치마크에서 수행된 실험을 통해 속도와 정확도의 상충 관계에 관한 고스트넷의 우수성을 보여줍니다. -The corresponding accuracy on ImageNet dataset with pretrained model is listed below. +사전 학습된 모델을 사용한 ImageNet 데이터셋에 따른 정확도는 아래에 나열되어 있습니다. | Model structure | FLOPs | Top-1 acc | Top-5 acc | | --------------- | ----------- | ----------- | ----------- | | GhostNet 1.0x | 142M | 73.98 | 91.46 | -### References +### 참고 -You can read the full paper at this [link](https://arxiv.org/abs/1911.11907). +다음 [링크](https://arxiv.org/abs/1911.11907)에서 논문의 전체적인 내용에 대하여 읽을 수 있습니다. >@inproceedings{han2019ghostnet, > title={GhostNet: More Features from Cheap Operations},