Skip to content

Commit a9e10eb

Browse files
committed
Rectify a remaining Pythonic reference
1 parent f9da7db commit a9e10eb

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

src/Adaboost.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ function learn(positiveIIs::AbstractArray, negativeIIs::AbstractArray, numClassi
155155
# featureWeight = 0.5 * log((1 - bestError) / bestError)
156156
featureWeight = (1 - bestError) / bestError # β
157157
# println(typeof(featureWeight))
158-
bestFeature.weight = featureWeight # need to element-wise alter the struct `weight`; else we get `setfield! immutable struct of type HaarLikeFeature cannot be changed`
158+
bestFeature.weight = featureWeight
159159
160160
# classifiers = vcat(classifiers, bestFeature)
161+
# println(classifiers)
161162
classifiers = push!(classifiers, bestFeature)
162163
163164
# update image weights $w_{t+1,i}=w_{t,i}\beta_{t}^{1-e_i}$
@@ -184,6 +185,7 @@ function learn(positiveIIs::AbstractArray, negativeIIs::AbstractArray, numClassi
184185
next!(p)
185186
end
186187

188+
# println(typeof(classifiers[1]))
187189
return classifiers
188190

189191
end

src/FDA.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ function main(alt::Bool=false)
6464
println("Determining classifiers; this may take a while...")
6565
classifiers = learn(facesIITraining, nonFacesIITraining, numClassifiers, minFeatureHeight, maxFeatureHeight, minFeatureWidth, maxFeatureWidth)
6666

67+
# [println(c) for c in classifiers]
68+
# println(typeof(classifiers))
69+
# for c in classifiers
70+
# println(typeof(c))
71+
# end
72+
6773
println("Loading test faces...")
6874
facesTesting = loadImages(posTestingPath)
6975
facesIITesting = map(toIntegralImage, facesTesting) # list(map(...))
@@ -79,9 +85,9 @@ function main(alt::Bool=false)
7985
correctNonFaces = length(nonFacesTesting) - sum(ensembleVoteAll(nonFacesIITesting, classifiers))
8086

8187
println("...done.\n\nResult:\n Faces: ", correctFaces, "/", length(faces_testing)
82-
, " (", ((float(correctFaces) / len(facesTesting)) * 100), "%)\n non-Faces: "
83-
, (correct_non_faces), "/", len(non_faces_testing), " ("
84-
, ((float(correct_non_faces) / len(non_faces_testing)) * 100), "%)")
88+
, " (", ((deepfloat(correctFaces) / length(facesTesting)) * 100), "%)\n non-Faces: "
89+
, (correct_non_faces), "/", length(non_faces_testing), " ("
90+
, ((deepfloat(correct_non_faces) / length(non_faces_testing)) * 100), "%)")
8591

8692
# Just for fun: putting all haar-like features over each other generates a face-like image
8793
recon = reconstruct(classifiers, size(facesTesting[1]))

src/Utils.jl

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ function ensembleVote(intImg::AbstractArray, classifiers::AbstractArray)
132132
# return 0
133133
# end
134134

135-
return (sum([c.get_vote(int_img) for c in classifiers]) >= 0 ? 1 : 0)
135+
# println([typeof(c) for c in classifiers])
136+
# println(typeof(classifiers))
137+
return deepsum([getVote(c, intImg) for c in classifiers]) >= 0 ? 1 : 0
138+
139+
# >= 0 ? 1 : 0
136140
end
137141

138142
function ensembleVoteAll(intImgs::AbstractArray, classifiers::AbstractArray)
@@ -148,9 +152,28 @@ function ensembleVoteAll(intImgs::AbstractArray, classifiers::AbstractArray)
148152
[type: Abstract Arrays (array of Integers)]
149153
=#
150154

151-
votePartial = partial(ensembleVote, classifiers)
155+
# [println(typeof(c)) for c in classifiers]
156+
# println(typeof(classifiers))
157+
158+
# votePartial = [partial(ensembleVote, c) for c in classifiers]
159+
# votePartial = partial(ensembleVote, [c for c in classifiers])
160+
# votePartial = partial(ensembleVote, classifiers)
161+
#
162+
# return map(votePartial, intImgs)
163+
164+
# map(i -> ensembleVote(classifiers, i), intImgs)
165+
return map(i -> ensembleVote(i, classifiers), intImgs)
166+
167+
# votePartial = partial(ensembleVote, intImgs)
168+
#
169+
# return map(votePartial, classifiers)
170+
171+
172+
# map(imgIDX -> (labels[imgIDX] ≠ votes[imgIDX, bestFeatureIDX]) ? weights[imgIDX] * featureWeight : weights[imgIDX] * featureWeight, 1:numImgs)
173+
#
174+
# map(i -> (), intImgs)
175+
#
152176

153-
return map(votePartial, intImgs)
154177
end
155178

156179

0 commit comments

Comments
 (0)