Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
licenseplates
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
licenseplates
Commits
5690b9e0
Commit
5690b9e0
authored
Dec 21, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added script that runs a given classifier and savesthe faulty classified images.
parent
d76c71c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
.gitignore
.gitignore
+1
-0
src/run_classifier.py
src/run_classifier.py
+63
-0
No files found.
.gitignore
View file @
5690b9e0
...
@@ -15,3 +15,4 @@ images/BBB
...
@@ -15,3 +15,4 @@ images/BBB
images/Images
images/Images
images/Infos
images/Infos
images/licenseplates
images/licenseplates
images/faulty
src/run_classifier.py
0 → 100755
View file @
5690b9e0
#!/usr/bin/python
from
cPickle
import
dump
,
load
from
sys
import
argv
,
exit
from
pylab
import
imsave
import
os
from
Classifier
import
Classifier
if
len
(
argv
)
<
3
:
print
'Usage: python %s NEIGHBOURS BLUR_SCALE'
%
argv
[
0
]
exit
(
1
)
neighbours
=
int
(
argv
[
1
])
blur_scale
=
float
(
argv
[
2
])
suffix
=
'_%s_%s'
%
(
blur_scale
,
neighbours
)
test_set_file
=
'test_set%s.dat'
%
suffix
classifier_file
=
'classifier%s.dat'
%
suffix
print
'Loading classifier...'
classifier
=
Classifier
(
filename
=
classifier_file
)
classifier
.
neighbours
=
neighbours
print
'Loading test set...'
test_set
=
load
(
file
(
test_set_file
,
'r'
))
l
=
len
(
test_set
)
matches
=
0
classified
=
{}
for
i
,
char
in
enumerate
(
test_set
):
prediction
=
classifier
.
classify
(
char
,
char
.
value
)
if
char
.
value
!=
prediction
:
key
=
'%s_as_%s'
%
(
char
.
value
,
prediction
)
if
key
not
in
classified
:
classified
[
key
]
=
[
char
]
else
:
classified
[
key
].
append
(
char
)
print
'"%s" was classified as "%s"'
\
%
(
char
.
value
,
prediction
)
else
:
matches
+=
1
print
'%d of %d (%d%% done)'
%
(
i
+
1
,
l
,
int
(
100
*
(
i
+
1
)
/
l
))
print
'
\
n
%d matches (%d%%), %d fails'
%
(
matches
,
\
int
(
100
*
matches
/
l
),
\
len
(
test_set
)
-
matches
)
print
'Saving faulty classified characters...'
folder
=
'../images/faulty/'
if
not
os
.
path
.
exists
(
folder
):
os
.
mkdir
(
folder
)
for
filename
,
l
in
classified
.
iteritems
():
if
len
(
l
)
==
1
:
imsave
(
'%s%s'
%
(
folder
,
filename
),
char
.
image
.
data
,
cmap
=
'gray'
)
else
:
for
i
,
char
in
enumerate
(
l
):
imsave
(
'%s%s_%d'
%
(
folder
,
filename
,
i
),
char
.
image
.
data
,
cmap
=
'gray'
)
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