ResNext WSL

import torch
model = torch.hub.load('facebookresearch/WSL-Images', 'resnext101_32x8d_wsl')
# or
# model = torch.hub.load('facebookresearch/WSL-Images', 'resnext101_32x16d_wsl')
# or
# model = torch.hub.load('facebookresearch/WSL-Images', 'resnext101_32x32d_wsl')
# or
#model = torch.hub.load('facebookresearch/WSL-Images', 'resnext101_32x48d_wsl')
model.eval()

所有预训练模型都期望输入图像以相同的方式进行归一化,即形状为 (3 x H x W) 的 3 通道 RGB 图像的 mini-batch,其中 HW 至少为 224。图像必须加载到 [0, 1] 范围内,然后使用 mean = [0.485, 0.456, 0.406]std = [0.229, 0.224, 0.225] 进行归一化。

这是一个示例执行。

# 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)
# sample execution (requires torchvision)
from PIL import Image
from torchvision import transforms
input_image = Image.open(filename)
preprocess = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    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

# move the input and model to GPU for speed if available
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
print(output[0])
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
print(torch.nn.functional.softmax(output[0], dim=0))

模型描述

提供的 ResNeXt 模型以弱监督方式在 9.4 亿 张公共图像上进行预训练,其中包含与 1000 个 ImageNet1K 同义词集匹配的 1.5K 标签,随后在 ImageNet1K 数据集上进行微调。有关模型训练的详细信息,请参阅 ECCV 2018 上发表的“探索弱监督预训练的极限”(https://arxiv.org/abs/1805.00932)。

我们提供了 4 种不同容量的模型。

模型#参数浮点运算次数 (FLOPS)Top-1 准确率Top-5 准确率
ResNeXt-101 32x8d88M16B82.296.4
ResNeXt-101 32x16d193M36B84.297.2
ResNeXt-101 32x32d466M87B85.197.5
ResNeXt-101 32x48d829M153B85.497.6

与从头开始训练相比,我们的模型显著提高了 ImageNet 上的训练准确性。我们的 ResNext-101 32x48d 模型在 ImageNet 上达到了 85.4% 的最先进准确性。

参考文献

使用亿级弱监督数据训练的 ResNext 模型。

模型类型: 视觉
提交者: Facebook AI