Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-220
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
2022-220
2022-220
Commits
08b46b72
Commit
08b46b72
authored
Nov 13, 2022
by
Pathirana K.P.G.I
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
5f25b674
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
testing.py
testing.py
+64
-0
No files found.
testing.py
0 → 100644
View file @
08b46b72
import
os
import
cv2
from
skimage
import
io
import
numpy
as
np
from
keras.models
import
Sequential
from
keras.layers
import
Dense
,
Activation
,
Flatten
,
Dropout
from
keras.layers
import
Conv2D
,
MaxPooling2D
data
=
np
.
load
(
'Processed_Data/data.npy'
)
target
=
np
.
load
(
'Processed_Data/target.npy'
)
# In[2]:
from
sklearn.model_selection
import
train_test_split
train_data
,
test_data
,
train_target
,
test_target
=
train_test_split
(
data
,
target
,
test_size
=
0.1
)
# In[3]:
model
=
Sequential
()
model
.
add
(
Conv2D
(
256
,
(
3
,
3
),
input_shape
=
data
.
shape
[
1
:]))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Conv2D
(
128
,
(
3
,
3
)))
model
.
add
(
Activation
(
'relu'
))
model
.
add
(
MaxPooling2D
(
pool_size
=
(
2
,
2
)))
model
.
add
(
Flatten
())
model
.
add
(
Dropout
(
0.5
))
model
.
add
(
Dense
(
64
,
activation
=
'relu'
))
model
.
add
(
Dense
(
10
,
activation
=
'softmax'
))
model
.
compile
(
loss
=
'categorical_crossentropy'
,
optimizer
=
'adam'
,
metrics
=
[
'accuracy'
])
model
.
load_weights
(
'model.h5'
)
rome_data_dic
=
{
0
:
'VI'
,
1
:
'II'
,
2
:
'I'
,
3
:
'VII'
,
4
:
'VIII'
,
5
:
'IV'
,
6
:
'IX'
,
7
:
'V'
,
8
:
'X'
,
9
:
'III'
}
img
=
cv2
.
imread
(
'Data/i/i_001.png'
)
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
resized
=
cv2
.
resize
(
gray
,
(
50
,
50
))
normalized
=
resized
/
255.0
reshaped
=
np
.
reshape
(
normalized
,
(
1
,
50
,
50
,
1
))
result
=
model
.
predict
(
reshaped
)
label
=
np
.
argmax
(
result
,
axis
=
1
)[
0
]
prob
=
np
.
max
(
result
,
axis
=
1
)[
0
]
prob
=
round
(
prob
,
2
)
*
100
# print(result)
print
(
np
.
argmax
(
result
,
axis
=
1
))
# print(np.max(result, axis=1)[0])
print
(
rome_data_dic
[
np
.
argmax
(
result
,
axis
=
1
)[
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