Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
22_23-J 65
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J 65
22_23-J 65
Commits
4759fe62
Commit
4759fe62
authored
Jan 30, 2023
by
Warnasooriya M.D.S.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get predictions
parent
c52cb39c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
Backend/SF__Dinuka_Pest_Damages_identification_V01.ipynb
Backend/SF__Dinuka_Pest_Damages_identification_V01.ipynb
+122
-0
No files found.
Backend/SF__Dinuka_Pest_Damages_identification_V01.ipynb
View file @
4759fe62
...
...
@@ -485,6 +485,128 @@
"source": [
"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": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment