Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-010
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
2021-010
2021-010
Commits
a343b138
Commit
a343b138
authored
Oct 18, 2021
by
Lahiru Sanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freshness analysis
parent
bafbaf7e
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1659 additions
and
0 deletions
+1659
-0
freshness/flask_server/app.py
freshness/flask_server/app.py
+147
-0
freshness/flask_server/templates/index.html
freshness/flask_server/templates/index.html
+498
-0
freshness/flask_server/templates/predict.html
freshness/flask_server/templates/predict.html
+479
-0
freshness/freshnessanalysis.html
freshness/freshnessanalysis.html
+46
-0
freshness/qualitycheck.html
freshness/qualitycheck.html
+489
-0
No files found.
freshness/flask_server/app.py
0 → 100644
View file @
a343b138
from
flask
import
Flask
,
render_template
,
redirect
,
url_for
import
os
import
cv2
from
matplotlib
import
image
import
numpy
as
np
from
numpy.lib.type_check
import
imag
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
from
tqdm
import
tqdm
from
random
import
shuffle
import
pickle
from
tensorflow.keras.utils
import
to_categorical
import
keras
from
keras.layers
import
Dense
,
Dropout
,
Conv2D
,
MaxPooling2D
,
Activation
,
Flatten
,
BatchNormalization
,
SeparableConv2D
from
keras.models
import
Sequential
from
keras.models
import
Model
,
load_model
from
PIL
import
Image
from
urllib
import
request
from
io
import
BytesIO
from
keras_preprocessing
import
image
import
urllib.request
import
tensorflow
as
tf
from
tensorflow.keras
import
datasets
,
layers
,
models
model
=
models
.
Sequential
()
new_model
=
load_model
(
'F:/EDUCATION/SLIIT/4thYear 1st semester/Research Project/python/python cnn/python cnn/Working/types.h5'
)
img
=
cv2
.
imread
(
"F:/EDUCATION/SLIIT/4thYear 1st semester/Research Project/python/python cnn/quality analysis/dataset/Banana/test/freshbanana/(102).png"
,
1
)
img
=
cv2
.
resize
(
img
,
(
50
,
50
))
img
=
np
.
reshape
(
img
,
[
1
,
50
,
50
,
3
])
predicted_value
=
np
.
argmax
(
model
.
predict
(
img
))
print
(
model
.
predict
(
img
))
type
=
""
if
predicted_value
==
0
:
type
=
"BANANA"
elif
predicted_value
==
1
:
type
=
"TOMATO"
else
:
type
=
"cant predict"
model
=
Sequential
()
model
.
add
(
Conv2D
(
32
,
(
3
,
3
),
kernel_initializer
=
'he_uniform'
,
padding
=
'same'
,
activation
=
'relu'
,
input_shape
=
(
100
,
100
,
3
)))
model
.
add
(
BatchNormalization
())
model
.
add
(
SeparableConv2D
(
32
,
(
3
,
3
),
kernel_initializer
=
'he_uniform'
,
padding
=
'same'
,
activation
=
'relu'
))
model
.
add
(
MaxPooling2D
((
2
,
2
)))
model
.
add
(
BatchNormalization
())
model
.
add
(
Dropout
(
0.3
))
model
.
add
(
SeparableConv2D
(
64
,
(
3
,
3
),
kernel_initializer
=
'he_uniform'
,
padding
=
'same'
,
activation
=
'relu'
))
model
.
add
(
SeparableConv2D
(
64
,
(
3
,
3
),
kernel_initializer
=
'he_uniform'
,
padding
=
'same'
,
activation
=
'relu'
))
model
.
add
(
BatchNormalization
())
model
.
add
(
MaxPooling2D
((
2
,
2
)))
model
.
add
(
Dropout
(
0.4
))
model
.
add
(
Conv2D
(
128
,
(
3
,
3
),
kernel_initializer
=
'he_uniform'
,
padding
=
'same'
,
activation
=
'relu'
))
model
.
add
(
Conv2D
(
128
,
(
3
,
3
),
kernel_initializer
=
'he_uniform'
,
padding
=
'same'
,
activation
=
'relu'
))
model
.
add
(
BatchNormalization
())
model
.
add
(
MaxPooling2D
((
2
,
2
)))
model
.
add
(
Dropout
(
0.5
))
model
.
add
(
Flatten
())
model
.
add
(
Dense
(
128
,
activation
=
'relu'
,
kernel_initializer
=
'he_uniform'
))
model
.
add
(
Dropout
(
0.3
))
model
.
add
(
Dense
(
1
,
activation
=
'sigmoid'
))
new_model
=
load_model
(
'F:/EDUCATION/SLIIT/4thYear 1st semester/Research Project/python/python cnn/quality analysis/dataset/Banana/working/rottenvsfresh.h5'
)
imge
=
cv2
.
imread
(
"F:/EDUCATION/SLIIT/4thYear 1st semester/Research Project/python/python cnn/quality analysis/dataset/Banana/test/freshbanana/(102).png"
,
1
)
imge
=
cv2
.
cvtColor
(
imge
,
cv2
.
COLOR_BGR2RGB
)
imge
=
cv2
.
resize
(
imge
,
(
100
,
100
))
imge
=
np
.
reshape
(
imge
,
[
1
,
100
,
100
,
3
])
imge
=
np
.
array
(
imge
)
.
astype
(
'float32'
)
/
255
predicted_value
=
model
.
predict_classes
(
imge
)
print
(
predicted_value
)
print
(
model
.
predict
(
imge
))
if
predicted_value
==
0
:
print
(
"fresh_banana"
)
elif
predicted_value
==
1
:
print
(
"rotten_banana"
)
else
:
print
(
"cant predict"
)
outputs
=
""
if
predicted_value
==
0
:
outputs
=
"Fresh Banana"
elif
predicted_value
==
1
:
outputs
=
"Rotten Banana"
else
:
outputs
=
"Cant predict"
app
=
Flask
(
__name__
)
@
app
.
route
(
'/'
)
def
Home
():
return
render_template
(
"index.html"
)
@
app
.
route
(
'/predict/<weight>/<paths>'
)
def
predict
(
weight
,
paths
):
gram
=
0.0
quality
=
""
size
=
""
weight1
=
float
(
weight
)
gram
=
weight1
*
1000
if
gram
<
114
:
size
=
"Small"
quality
=
"Grade A"
elif
gram
<
151
:
size
=
"Medium"
quality
=
"Grade B"
elif
gram
>
151
:
size
=
"Large"
quality
=
"Grade C"
else
:
size
=
"Cant predict"
return
render_template
(
"predict.html"
,
Predicted
=
outputs
,
type
=
type
,
weight
=
gram
,
sizee
=
size
,
qualityy
=
quality
,
paths
=
paths
)
if
__name__
==
"__main__"
:
app
.
run
(
debug
=
True
)
freshness/flask_server/templates/index.html
0 → 100644
View file @
a343b138
This diff is collapsed.
Click to expand it.
freshness/flask_server/templates/predict.html
0 → 100644
View file @
a343b138
This diff is collapsed.
Click to expand it.
freshness/freshnessanalysis.html
0 → 100644
View file @
a343b138
<html>
<head>
<title>
Cupertino Streaming
</title>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"
></script>
</head>
<body>
<h1>
Welcome to Orgi Check
</h1>
<img
src=
"http://192.168.1.6/"
alt=
"http://192.168.1.6/"
class=
"shrinkToFit"
width=
"404"
height=
"303"
>
<span
id=
"loadvalue"
>
0.0
</span>
</body>
</html>
<script>
var
xmlHttp
;
if
(
window
.
XMLHttpRequest
)
{
xmlHttp
=
new
XMLHttpRequest
();
}
else
if
(
window
.
ActiveXObject
)
{
xmlHttp
=
new
ActiveXObject
(
"
Microsoft.XMLHTTP
"
);
}
else
{
alert
(
"
Browser Doesnt Support Ajax!
"
);
}
if
(
xmlHttp
!==
null
)
{
xmlHttp
.
onreadystatechange
=
async
function
()
{
if
(
xmlHttp
.
readyState
===
4
)
{
var
res
=
xmlHttp
.
responseText
;
document
.
getElementById
(
"
loadvalue
"
).
innerHTML
=
res
;
}
};
xmlHttp
.
open
(
"
GET
"
,
"
http://192.168.1.5/GetValue/
"
,
true
);
xmlHttp
.
send
();
}
</script>
\ No newline at end of file
freshness/qualitycheck.html
0 → 100644
View file @
a343b138
This diff is collapsed.
Click to expand it.
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