|
444 | 444 | " " |
445 | 445 | ] |
446 | 446 | }, |
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 | | - }, |
490 | 447 | { |
491 | 448 | "cell_type": "code", |
492 | 449 | "execution_count": null, |
|
497 | 454 | " images_so_far = 0\n", |
498 | 455 | " fig = plt.figure()\n", |
499 | 456 | "\n", |
500 | | - " for inputs, labels in tqdm.tqdm(dataloaders['valid']):\n", |
| 457 | + " for inputs, labels in tqdm.tqdm(dataloaders['test']):\n", |
501 | 458 | " outputs = model(inputs)\n", |
502 | 459 | " _, preds = torch.max(outputs.data, 1)\n", |
503 | 460 | " for j in range(inputs.size()[0]):\n", |
|
0 commit comments