Commit 4759fe62 authored by Warnasooriya M.D.S.'s avatar Warnasooriya M.D.S.

Get predictions

parent c52cb39c
...@@ -485,6 +485,128 @@ ...@@ -485,6 +485,128 @@
"source": [ "source": [
"plot_loss_curve(resnet_hist)" "plot_loss_curve(resnet_hist)"
] ]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ydvjG5N-IG7a"
},
"source": [
"# 🟢 Make Predictions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "j1mHbvSWKJFn"
},
"outputs": [],
"source": [
"#Create a function to improt an image and resize it to be able to used with our model\n",
"def load_and_prep_image(filename , img_shape=448):\n",
" \"\"\"\n",
" Reads an image from file name , turns it into a tensor and reshapes it to (img_shape , color_channel\n",
" \"\"\"\n",
" print('FILe Name type - ', type(filename))\n",
" #Read in the image\n",
" img = tf.io.read_file(filename)\n",
" print('img 1- ', type(img))\n",
"\n",
" #Decode the read file into a tensor\n",
" img = tf.image.decode_image(img)\n",
" print('img 2- ', type(img))\n",
"\n",
" #Resiz the Image\n",
" img = tf.image.resize(img , size=[img_shape , img_shape])\n",
"\n",
" #Re scale the image - get all values between 0 and 255\n",
" img = img/255.\n",
"\n",
" return img\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "j1mHbvSWKJFn"
},
"outputs": [],
"source": [
"#Create a function to improt an image and resize it to be able to used with our model\n",
"def load_and_prep_image(filename , img_shape=448):\n",
" \"\"\"\n",
" Reads an image from file name , turns it into a tensor and reshapes it to (img_shape , color_channel\n",
" \"\"\"\n",
" print('FILe Name type - ', type(filename))\n",
" #Read in the image\n",
" img = tf.io.read_file(filename)\n",
" print('img 1- ', type(img))\n",
"\n",
" #Decode the read file into a tensor\n",
" img = tf.image.decode_image(img)\n",
" print('img 2- ', type(img))\n",
"\n",
" #Resiz the Image\n",
" img = tf.image.resize(img , size=[img_shape , img_shape])\n",
"\n",
" #Re scale the image - get all values between 0 and 255\n",
" img = img/255.\n",
"\n",
" return img\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 351
},
"id": "VZv8GfDMIZoJ",
"outputId": "9af472d3-9570-4779-a185-809cae5032f0"
},
"outputs": [],
"source": [
"image_path = \"/content/Damage Data/Testing/Mealybug/5436367-PPT.jpg\"\n",
"pred_and_plot(resnet_model , image_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 351
},
"id": "mYHZo1fW5Das",
"outputId": "7af9c19c-6bc4-4123-f7ae-74b94b78f9f0"
},
"outputs": [],
"source": [
"image_path = \"/content/Damage Data/Testing/Leaf miner/1223124-PPT.jpg\"\n",
"pred_and_plot(resnet_model , image_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 351
},
"id": "mYHZo1fW5Das",
"outputId": "7af9c19c-6bc4-4123-f7ae-74b94b78f9f0"
},
"outputs": [],
"source": [
"image_path = \"/content/Damage Data/Testing/Leaf miner/1223124-PPT.jpg\"\n",
"pred_and_plot(resnet_model , image_path)"
]
} }
], ],
"metadata": { "metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment