Skip to content

Commit d8c46a6

Browse files
Add files via upload
1 parent f0d3321 commit d8c46a6

File tree

1 file changed

+1
-44
lines changed

1 file changed

+1
-44
lines changed

examples/image_classification_tutorial_boilerplate.ipynb

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -444,49 +444,6 @@
444444
" "
445445
]
446446
},
447-
{
448-
"cell_type": "code",
449-
"execution_count": null,
450-
"metadata": {
451-
"colab": {},
452-
"colab_type": "code",
453-
"id": "oASN5m6Ibn9l",
454-
"tags": []
455-
},
456-
"outputs": [],
457-
"source": [
458-
"images_so_far = 0\n",
459-
"fig = plt.figure()\n",
460-
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
461-
"test_model = torch.load(model_name)\n",
462-
"num_images = 1\n",
463-
"test_model.eval()\n",
464-
"test_loader = tqdm.tqdm(dataloaders[\"test\"])\n",
465-
"\n",
466-
"\n",
467-
"images_so_far = 0\n",
468-
" fig = plt.figure()\n",
469-
"\n",
470-
" for i, data in enumerate(dataloaders['val']):\n",
471-
" inputs, labels = data\n",
472-
" inputs, labels = Variable(inputs.cuda()), Variable(labels.cuda())\n",
473-
"\n",
474-
" outputs = model(inputs)\n",
475-
" _, preds = torch.max(outputs.data, 1)\n",
476-
"\n",
477-
" for j in range(inputs.size()[0]):\n",
478-
" images_so_far += 1\n",
479-
" ax = plt.subplot(num_images//2, 2, images_so_far)\n",
480-
" ax.axis('off')\n",
481-
" ax.set_title('predicted: {}'.format(class_names[preds[j]]))\n",
482-
" imshow(inputs.cpu().data[j])\n",
483-
"\n",
484-
" if images_so_far == num_images:\n",
485-
" return\n",
486-
"\n",
487-
"print('Accuracy of the network on the test images: %d %%' % (100 * (correct_preds / total)))"
488-
]
489-
},
490447
{
491448
"cell_type": "code",
492449
"execution_count": null,
@@ -497,7 +454,7 @@
497454
" images_so_far = 0\n",
498455
" fig = plt.figure()\n",
499456
"\n",
500-
" for inputs, labels in tqdm.tqdm(dataloaders['valid']):\n",
457+
" for inputs, labels in tqdm.tqdm(dataloaders['test']):\n",
501458
" outputs = model(inputs)\n",
502459
" _, preds = torch.max(outputs.data, 1)\n",
503460
" for j in range(inputs.size()[0]):\n",

0 commit comments

Comments
 (0)