|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 3, |
| 6 | + "id": "c3b1f8b5", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [ |
| 9 | + { |
| 10 | + "name": "stdout", |
| 11 | + "output_type": "stream", |
| 12 | + "text": [ |
| 13 | + "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 268ms/step\n", |
| 14 | + "[[6.0338993e-03 7.7998161e-01 2.1396168e-01 1.0594837e-06 6.9830060e-07\n", |
| 15 | + " 7.2607581e-06 1.1450890e-06 3.5322621e-06 2.3652308e-06 6.7957494e-06]]\n", |
| 16 | + "Predicted class: 1\n" |
| 17 | + ] |
| 18 | + } |
| 19 | + ], |
| 20 | + "source": [ |
| 21 | + "from tensorflow.keras.models import load_model\n", |
| 22 | + "from tensorflow.keras.preprocessing import image\n", |
| 23 | + "import numpy as np\n", |
| 24 | + "\n", |
| 25 | + "model = load_model(\"../models/model.keras\")\n", |
| 26 | + "img = image.load_img(\"../data/test_images/healthy.jpeg\", target_size=(128,128))\n", |
| 27 | + "img_array = np.expand_dims(image.img_to_array(img) / 255.0, 0)\n", |
| 28 | + "pred = model.predict(img_array)\n", |
| 29 | + "print(pred)\n", |
| 30 | + "print(\"Predicted class:\", np.argmax(pred))\n" |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "code", |
| 35 | + "execution_count": null, |
| 36 | + "id": "45e22b67", |
| 37 | + "metadata": {}, |
| 38 | + "outputs": [], |
| 39 | + "source": [] |
| 40 | + } |
| 41 | + ], |
| 42 | + "metadata": { |
| 43 | + "kernelspec": { |
| 44 | + "display_name": "Python 3", |
| 45 | + "language": "python", |
| 46 | + "name": "python3" |
| 47 | + }, |
| 48 | + "language_info": { |
| 49 | + "codemirror_mode": { |
| 50 | + "name": "ipython", |
| 51 | + "version": 3 |
| 52 | + }, |
| 53 | + "file_extension": ".py", |
| 54 | + "mimetype": "text/x-python", |
| 55 | + "name": "python", |
| 56 | + "nbconvert_exporter": "python", |
| 57 | + "pygments_lexer": "ipython3", |
| 58 | + "version": "3.13.2" |
| 59 | + } |
| 60 | + }, |
| 61 | + "nbformat": 4, |
| 62 | + "nbformat_minor": 5 |
| 63 | +} |
0 commit comments