Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-262
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
2023-262
2023-262
Commits
7a3a7323
Commit
7a3a7323
authored
Sep 19, 2023
by
user
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rebase Flower Freshness
parent
863511d3
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
478 deletions
+0
-478
Disease_identification/.gitkeep
Disease_identification/.gitkeep
+0
-0
Disease_identification/flower_disease_identification.ipynb
Disease_identification/flower_disease_identification.ipynb
+0
-393
Disease_identification/model/.gitkeep
Disease_identification/model/.gitkeep
+0
-0
app_disease.py
app_disease.py
+0
-85
No files found.
Disease_identification/.gitkeep
deleted
100644 → 0
View file @
863511d3
Disease_identification/flower_disease_identification.ipynb
deleted
100644 → 0
View file @
863511d3
This diff is collapsed.
Click to expand it.
Disease_identification/model/.gitkeep
deleted
100644 → 0
View file @
863511d3
app_disease.py
deleted
100644 → 0
View file @
863511d3
import
base64
import
datetime
import
cv2
as
cv
import
numpy
as
np
import
pandas
as
pd
from
tkinter
import
*
import
firebase_admin
import
tensorflow
as
tf
import
tkinter.filedialog
from
firebase_admin
import
db
from
PIL
import
ImageTk
,
Image
from
firebase_admin
import
credentials
node
=
'flower_disease'
model
=
tf
.
keras
.
models
.
load_model
(
'models/flower_disease_detector.h5'
)
cred
=
credentials
.
Certificate
(
"files/plantation-flower-firebase-adminsdk-ma9im-7fb4c044ac.json"
)
default_app
=
firebase_admin
.
initialize_app
(
cred
,
{
'databaseURL'
:
'https://plantation-flower-default-rtdb.firebaseio.com/'
})
ref_node
=
db
.
reference
(
node
)
def
inference_disease
(
image_path
,
target_size
=
(
224
,
224
),
class_dict
=
{
0
:
'Black Spot'
,
1
:
'Downy Mildew'
,
2
:
'Fresh Leaf'
}
):
class_dict_rev
=
dict
((
v
,
k
)
for
k
,
v
in
class_dict
.
items
())
img_file
=
image_path
.
split
(
'/'
)[
-
2
]
image
=
cv
.
imread
(
image_path
)
image
=
cv
.
cvtColor
(
image
,
cv
.
COLOR_BGR2RGB
)
image
=
cv
.
resize
(
image
,
target_size
)
image
=
np
.
expand_dims
(
image
,
axis
=
0
)
image
=
tf
.
keras
.
applications
.
xception
.
preprocess_input
(
image
)
pred
=
model
.
predict
(
image
,
verbose
=
0
)
.
squeeze
()
pred
=
np
.
argmax
(
pred
)
pred
=
class_dict
[
class_dict_rev
[
img_file
]]
return
pred
def
write_data_firebase
(
image_path
,
disease
,
):
image_path
=
image_path
.
replace
(
'
\\
'
,
'/'
)
file_name
=
image_path
.
split
(
'/'
)[
-
1
]
.
split
(
'.'
)[
0
]
.
strip
()
presentDate
=
datetime
.
datetime
.
now
()
unix_timestamp
=
int
(
datetime
.
datetime
.
timestamp
(
presentDate
)
*
1000
)
# # convert image to base64 & store in firebase
# with open(image_path, "rb") as image_file:
# encoded_string = base64.b64encode(image_file.read())
prefix
=
'data:image/jpeg;base64,'
image_np
=
cv
.
imread
(
image_path
)
image_np
=
cv
.
cvtColor
(
image_np
,
cv
.
COLOR_BGR2RGB
)
image_np
=
cv
.
resize
(
image_np
,
(
500
,
500
))
_
,
buffer
=
cv
.
imencode
(
'.jpg'
,
image_np
)
encoded_string
=
base64
.
b64encode
(
buffer
)
encoded_string
=
encoded_string
.
decode
(
'utf-8'
)
data
=
{
"image"
:
f
"{prefix}{encoded_string}"
,
"disease"
:
f
"{disease}"
,
"timestamp"
:
unix_timestamp
}
ref_node
.
push
(
data
)
image_path
=
tkinter
.
filedialog
.
askopenfilename
(
initialdir
=
'data/flower_disease_type_dataset/'
,
title
=
'Select Image'
,
filetypes
=
((
'JPG Files'
,
'*.JPG'
),
(
'All Files'
,
'*.*'
))
)
disease
=
inference_disease
(
image_path
)
write_data_firebase
(
image_path
,
disease
)
image
=
Image
.
open
(
image_path
)
image
=
image
.
resize
((
400
,
400
),
Image
.
Resampling
.
LANCZOS
)
image
=
ImageTk
.
PhotoImage
(
image
)
image_label
=
Label
(
image
=
image
)
image_label
.
image
=
image
image_label
.
grid
(
row
=
0
,
column
=
0
,
columnspan
=
3
)
print
(
'Disease: '
,
disease
)
\ No newline at end of file
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