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
975e121e
Commit
975e121e
authored
Jan 28, 2023
by
dulanthaM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getting data completed
parent
b79a6926
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
180 additions
and
0 deletions
+180
-0
Backend/SF_Dulantha_Dificiency_identificationV1.ipynb
Backend/SF_Dulantha_Dificiency_identificationV1.ipynb
+180
-0
No files found.
Backend/SF_Dulantha_Dificiency_identificationV1.ipynb
0 → 100644
View file @
975e121e
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "Y2jOdgL3j-o8"
},
"source": [
"# 🟨 Getting the Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lDXyIngTMaXf",
"outputId": "eb920137-7143-4c2c-e43e-a0aa82d93b49"
},
"outputs": [],
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "t-ZDw43fiy-1"
},
"outputs": [],
"source": [
"data_location = '/content/drive/MyDrive/RP_SmartFarmer/Dulantha Madhushan - Nutrient deficiency/Dataset/Dificiency Data.rar'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "widI8pNLhUci",
"outputId": "13c35bb6-dd84-4ffd-f585-402d31aeaa41"
},
"outputs": [],
"source": [
"!pip install patool"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 105
},
"id": "U-MmiQnjF9gG",
"outputId": "3d634674-631e-4ed7-d8d7-708c1f9050f5"
},
"outputs": [],
"source": [
"import patoolib\n",
"patoolib.extract_archive(data_location, outdir=\"/content\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_YdAEKT6GSoX",
"outputId": "4fdd684c-a8b2-4fa3-ee3e-91cd0c9ec280"
},
"outputs": [],
"source": [
"import os\n",
"for dirpath , dirnames , filenames in os.walk(\"Dificiency Data\"):\n",
" print(f\"There are {len(dirnames)} directories and {len(filenames)} images in '{dirpath}'.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "gLo3FV6OGVP0",
"outputId": "c9f815fd-004f-44d5-dba0-745f657c09fb"
},
"outputs": [],
"source": [
"train_dir = \"Dificiency Data/Trainig\"\n",
"test_dir = \"Dificiency Data/Testing\"\n",
"\n",
"#lets get the class names\n",
"import pathlib\n",
"import numpy as np\n",
"\n",
"data_dir = pathlib.Path(train_dir)\n",
"class_names = np.array(sorted([item.name for item in data_dir.glob('*')]))\n",
"print(class_names)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "vVCpvSuKlGG1"
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import matplotlib.image as mpimg\n",
"import random\n",
"import os\n",
"\n",
"def view_random_image(target_dir , target_class):\n",
" target_folder = target_dir+\"/\"+target_class\n",
" random_image = random.sample(os.listdir(target_folder) ,1)\n",
"\n",
" img = mpimg.imread(target_folder+\"/\"+random_image[0])\n",
" plt.imshow(img)\n",
" plt.title(target_class)\n",
" plt.axis(\"off\")\n",
"\n",
" print(f\"Image Shape:{img.shape}\") \n",
"\n",
" return img"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "tVx10O9CGXn2",
"outputId": "173a0a39-9cfa-4f76-cf91-9e67e7da54d0"
},
"outputs": [],
"source": [
"import random\n",
"img = view_random_image(target_dir=train_dir , \n",
" target_class = random.choice(class_names))"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [
"Y2jOdgL3j-o8",
"HvDEsB_fj7_7",
"RFJbEeyUlUgn",
"z_3CSlVYgcU7",
"gx3orjVQMLLt"
],
"provenance": []
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
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