{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import tensorflow as tf\n", "from tensorflow.keras.models import load_model\n", "import matplotlib.pyplot as plt\n", "from PIL import Image\n", "import mlflow\n", "#import torch\n", "#from torchvision import models" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING:absl:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.\n" ] } ], "source": [ "\n", "# Load the model from an .h5 file\n", "model = load_model('resnet50_v3_callbacks.h5')" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e86d6686fa1a4334940fc19c6ec726ec", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading artifacts: 0%| | 0/6 [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "img_path = 'C:/Users/vsavelev/GITHUB/DS_projet/LAYER2/MO/validation/373/145025.jpg'\n", "heatmap = gradcam_with_display(model, img_path, pred_index=None, alpha=0.4)\n" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }