<jupyter_start><jupyter_text>Reference: https://gist.github.com/jkarimi91/d393688c4d4cdb9251e3f939f138876e Get the labels used to train VGG<jupyter_code>response = requests.get('https://s3.amazonaws.com/outcome-blog/imagenet/labels.json')
labels = {int(key): value for key, value in response.json().items()}<jupyter_output><empty_output><jupyter_text>Load the pretrained VGG-16 model<jupyter_code>vgg16 = models.vgg16(pretrained=True)
params_count = sum(p.numel() for p in vgg16.parameters() if p.requires_grad)
print('Tunable params:', params_count)<jupyter_output>Tunable params: 138357544<jupyter_text>Load the fake dataset with only one image of a dog inside<jupyter_code>coco = CocoDataset('../data/contents')<jupyter_output><empty_output><jupyter_text>Get the model output<jupyter_code>outputs = vgg16(coco[0].unsqueeze(0))
_, preds = torch.max(outputs.data, 1)
print(labels[preds.item()])<jupyter_output>Labrador retriever<jupyter_text>Same on the first few images of the real dataset, using a dataloader<jupyter_code>coco = CocoDataset('../data/coco_data')
data_loader = torch.utils.data.DataLoader(coco, batch_size=4, shuffle=True)
one_batch_images = next(iter(data_loader))
outputs = vgg16(one_batch_images)
_, preds = torch.max(outputs.data, 1)
for i, image in enumerate(one_batch_images):
    display_image(image, labels[preds[i].item()])<jupyter_output>Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
{'fraction_non_alphanumeric': 0.12188365650969529, 'fraction_numerical': 0.04155124653739612, 'mean_word_length': 6.462809917355372, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '66156', 'license': 'MIT', 'n_tokens_mistral': 688, 'n_tokens_neox': 637, 'n_words': 163, 'path': 'src/test_vgg_16_original_output.ipynb', 'repo_name': 'ThomasRanvier/cnn_style_transfer', 'size': '1805'}