PyTorch で学ぶ画像向け Deep Learning
Michal Oleszak
Machine Learning Engineer
物体認識は画像内の物体を特定します:
各物体の位置(バウンディングボックス)
各物体のクラスラベル
用途: 監視、医用診断、交通管理、スポーツ分析



![]()
ToTensor() による変換
import torchvision.transforms as transformstransform = transforms.Compose([ transforms.Resize(224), transforms.ToTensor() ]) image_tensor = transform(image)
PILToTensor() による変換
import torchvision.transforms as transforms
transform = transforms.Compose([
transforms.Resize(224),
transforms.PILToTensor()
])
image_tensor = transform(image)
from torchvision.utils import draw_bounding_boxesbbox = torch.tensor([x_min, y_min, x_max, y_max]) bbox = bbox.unsqueeze(0)bbox_image = draw_bounding_boxes( image_tensor, bbox, width=3, colors="red" )transform = transforms.Compose([ transforms.ToPILImage() ]) pil_image = transform(bbox_image) import matplotlib.pyplot as plt plt.imshow(pil_image)
draw_bounding_boxes をインポート
PyTorch で学ぶ画像向け Deep Learning