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
8b054155
Commit
8b054155
authored
Jan 31, 2023
by
Manukalpani G.S. IT19111698
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensemble model part one added
parent
adf10677
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
0 deletions
+126
-0
Backend/.ipynb_checkpoints/SF_Weed_identification_Finalized-checkpoint.ipynb
...kpoints/SF_Weed_identification_Finalized-checkpoint.ipynb
+63
-0
Backend/SF_Weed_identification_Finalized.ipynb
Backend/SF_Weed_identification_Finalized.ipynb
+63
-0
No files found.
Backend/.ipynb_checkpoints/SF_Weed_identification_Finalized-checkpoint.ipynb
View file @
8b054155
...
@@ -460,6 +460,69 @@
...
@@ -460,6 +460,69 @@
"source": [
"source": [
"efficientNet_model_top.save('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_top_view2.h5')"
"efficientNet_model_top.save('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_top_view2.h5')"
]
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"🟩 03 -Combining Two Models - Ensemble Approach"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Getting a copy of the saved model to colab\n",
"import shutil \n",
"\n",
"shutil.copy('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_top_view2.h5' , '/content')\n",
"shutil.copy('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_side_view2.h5', '/content')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def load_all_models():\n",
" all_models = []\n",
" model_names = ['Weed_top_view2.h5', 'Weed_side_view2.h5']\n",
" for model_name in model_names:\n",
" filename = os.path.join('/content', model_name)\n",
" model = tf.keras.models.load_model(filename , custom_objects={'KerasLayer':hub.KerasLayer})\n",
" all_models.append(model)\n",
" print('loaded:', filename)\n",
" return all_models"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"models = load_all_models()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tensorflow.keras.models import Model , load_model\n",
"from tensorflow.keras.layers import Input, Average\n",
"\n",
"model_input = Input(shape = (224, 224, 3))\n",
"model_outputs = [model(model_input) for model in models]\n",
"ensemble_output = Average()(model_outputs)\n",
"ensemble_model = Model(inputs = model_input , outputs = ensemble_output , name = 'ensemble')"
]
}
}
],
],
"metadata": {
"metadata": {
...
...
Backend/SF_Weed_identification_Finalized.ipynb
View file @
8b054155
...
@@ -460,6 +460,69 @@
...
@@ -460,6 +460,69 @@
"source": [
"source": [
"efficientNet_model_top.save('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_top_view2.h5')"
"efficientNet_model_top.save('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_top_view2.h5')"
]
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"🟩 03 -Combining Two Models - Ensemble Approach"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Getting a copy of the saved model to colab\n",
"import shutil \n",
"\n",
"shutil.copy('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_top_view2.h5' , '/content')\n",
"shutil.copy('/content/drive/MyDrive/RP_SmartFarmer/Sandhini Gamage - Weed identification /private/saved_models/Weed_side_view2.h5', '/content')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def load_all_models():\n",
" all_models = []\n",
" model_names = ['Weed_top_view2.h5', 'Weed_side_view2.h5']\n",
" for model_name in model_names:\n",
" filename = os.path.join('/content', model_name)\n",
" model = tf.keras.models.load_model(filename , custom_objects={'KerasLayer':hub.KerasLayer})\n",
" all_models.append(model)\n",
" print('loaded:', filename)\n",
" return all_models"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"models = load_all_models()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tensorflow.keras.models import Model , load_model\n",
"from tensorflow.keras.layers import Input, Average\n",
"\n",
"model_input = Input(shape = (224, 224, 3))\n",
"model_outputs = [model(model_input) for model in models]\n",
"ensemble_output = Average()(model_outputs)\n",
"ensemble_model = Model(inputs = model_input , outputs = ensemble_output , name = 'ensemble')"
]
}
}
],
],
"metadata": {
"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