Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
licenseplates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
licenseplates
Commits
1a203e67
Commit
1a203e67
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Merged test scripts into a single test file: find_svm_parameter.py.
parent
7a67ea01
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/load_characters.py
+11
-6
11 additions, 6 deletions
src/load_characters.py
src/load_learning_set.py
+40
-0
40 additions, 0 deletions
src/load_learning_set.py
src/test_classifier.py
+10
-40
10 additions, 40 deletions
src/test_classifier.py
with
61 additions
and
46 deletions
src/load_characters.py
+
11
−
6
View file @
1a203e67
#!/usr/bin/python
from
os
import
listdir
from
cPickle
import
dump
from
pylab
import
imshow
,
show
from
sys
import
argv
,
exit
from
GrayscaleImage
import
GrayscaleImage
from
NormalizedCharacterImage
import
NormalizedCharacterImage
from
Character
import
Character
if
len
(
argv
)
<
4
:
print
'
Usage: python %s FILE_SUFFIX BLUR_SCALE NEIGHBOURS
'
%
argv
[
0
]
exit
(
1
)
c
=
[]
for
char
in
sorted
(
listdir
(
'
../images/LearningSet
'
)):
for
image
in
sorted
(
listdir
(
'
../images/LearningSet/
'
+
char
)):
f
=
'
../images/LearningSet/
'
+
char
+
'
/
'
+
image
image
=
GrayscaleImage
(
f
)
norm
=
NormalizedCharacterImage
(
image
,
blur
=
1
,
size
=
(
48
,
36
)
)
#
imshow(norm.data, cmap='gray')
#show()
norm
=
NormalizedCharacterImage
(
image
,
blur
=
float
(
argv
[
2
]),
height
=
42
)
#
from pylab import imshow, show
#
imshow(norm.data, cmap='gray');
show()
character
=
Character
(
char
,
[],
norm
)
character
.
get_single_cell_feature_vector
()
character
.
get_single_cell_feature_vector
(
int
(
argv
[
3
])
)
c
.
append
(
character
)
print
char
dump
(
c
,
open
(
'
characters.dat
'
,
'
w+
'
))
print
'
Saving characters...
'
dump
(
c
,
open
(
'
characters%s.dat
'
%
argv
[
1
],
'
w+
'
))
This diff is collapsed.
Click to expand it.
src/load_learning_set.py
0 → 100755
+
40
−
0
View file @
1a203e67
#!/usr/bin/python
from
cPickle
import
dump
,
load
from
sys
import
argv
,
exit
if
len
(
argv
)
<
2
:
print
'
Usage: python %s FILE_SUFFIX
'
%
argv
[
0
]
exit
(
1
)
print
'
Loading characters...
'
chars
=
load
(
file
(
'
characters%s.dat
'
%
argv
[
1
],
'
r
'
))
learning_set
=
[]
test_set
=
[]
#s = {}
#
#for char in chars:
# if char.value not in s:
# s[char.value] = [char]
# else:
# s[char.value].append(char)
#
#for value, chars in s.iteritems():
# learning_set += chars[::2]
# test_set += chars[1::2]
learned
=
[]
for
char
in
chars
:
if
learned
.
count
(
char
.
value
)
==
70
:
test_set
.
append
(
char
)
else
:
learning_set
.
append
(
char
)
learned
.
append
(
char
.
value
)
print
'
Learning set:
'
,
[
c
.
value
for
c
in
learning_set
]
print
'
\n
Test set:
'
,
[
c
.
value
for
c
in
test_set
]
print
'
\n
Saving learning set...
'
dump
(
learning_set
,
file
(
'
learning_set%s.dat
'
%
argv
[
1
],
'
w+
'
))
print
'
Saving test set...
'
dump
(
test_set
,
file
(
'
test_set%s.dat
'
%
argv
[
1
],
'
w+
'
))
This diff is collapsed.
Click to expand it.
src/test_classifier.py
+
10
−
40
View file @
1a203e67
#!/usr/bin/python
from
xml_helper_functions
import
xml_to_LicensePlate
from
Classifier
import
Classifier
from
cPickle
import
dump
,
load
chars
=
load
(
file
(
'
characters.dat
'
,
'
r
'
))
learning_set
=
[]
test_set
=
[]
#s = {}
#
#for char in chars:
# if char.value not in s:
# s[char.value] = [char]
# else:
# s[char.value].append(char)
#
#for value, chars in s.iteritems():
# learning_set += chars[::2]
# test_set += chars[1::2]
learned
=
[]
from
Classifier
import
Classifier
for
char
in
chars
:
if
learned
.
count
(
char
.
value
)
==
70
:
test_set
.
append
(
char
)
else
:
learning_set
.
append
(
char
)
learned
.
append
(
char
.
value
)
if
len
(
argv
)
<
5
:
print
'
Usage: python %s FILE_SUFFIX C GAMMA NEIGHBOURS
'
%
argv
[
0
]
exit
(
1
)
print
'
Learning set:
'
,
[
c
.
value
for
c
in
learning_set
]
print
'
Test set:
'
,
[
c
.
value
for
c
in
test_set
]
print
'
Saving learning set...
'
dump
(
learning_set
,
file
(
'
learning_set.dat
'
,
'
w+
'
))
print
'
Saving test set...
'
dump
(
test_set
,
file
(
'
test_set.dat
'
,
'
w+
'
))
#----------------------------------------------------------------
print
'
Loading learning set
'
learning_set
=
load
(
file
(
'
learning_set.dat
'
,
'
r
'
))
learning_set
=
load
(
file
(
'
learning_set
%s
.dat
'
%
argv
[
1
]
,
'
r
'
))
# Train the classifier with the learning set
classifier
=
Classifier
(
c
=
512
,
gamma
=
.
125
,
cell_size
=
12
)
classifier
=
Classifier
(
c
=
float
(
argv
[
1
]),
\
gamma
=
float
(
argv
[
2
]),
\
neighbours
=
int
(
argv
[
3
]))
classifier
.
train
(
learning_set
)
classifier
.
save
(
'
classifier.dat
'
)
print
'
Saved classifier
'
#----------------------------------------------------------------
print
'
Loading classifier
'
classifier
=
Classifier
(
filename
=
'
classifier.dat
'
)
print
'
Loading test set
'
test_set
=
load
(
file
(
'
test_set.dat
'
,
'
r
'
))
test_set
=
load
(
file
(
'
test_set
%s
.dat
'
%
argv
[
1
]
,
'
r
'
))
l
=
len
(
test_set
)
matches
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment