Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOG not working #48

Closed
davidbp opened this issue Feb 3, 2018 · 20 comments
Closed

HOG not working #48

davidbp opened this issue Feb 3, 2018 · 20 comments

Comments

@davidbp
Copy link
Contributor

davidbp commented Feb 3, 2018

Hello,
I have tried the HOG code but it does not seem to work.
The following code:

img = testimage("lena_gray")
create_descriptor(img, HOG()) 

returns

BoundsError: attempt to access 9×32×32 Array{Float64,3} at index [10, 1, 1]

Stacktrace:
 [1] trilinear_interpolate!(::Array{Float64,3}, ::Float32, ::Float32, ::Int64, ::CartesianIndex{2}, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64) at /Users/davidbuchaca1/.julia/v0.6/ImageFeatures/src/hog.jl:132
 [2] create_hog_descriptor(::Array{Float32,2}, ::Array{Float32,2}, ::ImageFeatures.HOG) at /Users/davidbuchaca1/.julia/v0.6/ImageFeatures/src/hog.jl:82
 [3] create_descriptor(::Array{ColorTypes.Gray{FixedPointNumbers.Normed{UInt8,8}},2}, ::ImageFeatures.HOG) at /Users/davidbuchaca1/.julia/v0.6/ImageFeatures/src/hog.jl:34
 [4] include_string(::String, ::String) at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib:?

Am I doing something wrong?

@colbec
Copy link

colbec commented Mar 17, 2018

I have the same issue when running the train script on openSUSE 42.3 using the published binary for Julia 0.6. It stops at the first image in the humans directory (./humans/per00001.ppm) with a message similar to the one reported.

ERROR: LoadError: BoundsError: attempt to access 9×16×8 Array{Float64,3} at index [10, 1, 1]

@zygmuntszpak
Copy link
Member

This bug is resolved on the master branch but a release was subsequently never tagged. Hence when you do Pkg.add("ImageFeatures") you currently don't get the latest version. If you checkout the master branch things will work as expected. It looks like tejus-gupta fixed the problem as part of commit #42. @Evizero could you please tag a release when you have a spare moment?

@Evizero
Copy link
Member

Evizero commented Mar 18, 2018

Thanks for the reminder

JuliaLang/METADATA.jl#13878

@colbec
Copy link

colbec commented Mar 18, 2018

Thanks for this, which fixes that particular issue; now the process stops when trying to process the non_human images, finding an issue with incompatible images, the size of which must be a multiple of the cell size:

 ERROR: LoadError: Height and Width of the image must be a multiple of cell_size.
Stacktrace:
 [1] create_hog_descriptor(::Array{Float64,2}, ::Array{Float64,2}, ::ImageFeatures.HOG) at /home/colin/.julia/v0.6/ImageFeatures/src/hog.jl:67
 [2] create_descriptor(::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::ImageFeatures.HOG) at /home/colin/.julia/v0.6/ImageFeatures/src/hog.jl:56
 [3] macro expansion at /home/colin/data/hog/train2.jl:18 [inlined]
 [4] anonymous at ./<missing>:?
 [5] include_from_node1(::String) at ./loading.jl:569
 [6] include(::String) at ./sysimg.jl:14
 [7] process_options(::Base.JLOptions) at ./client.jl:305
 [8] _start() at ./client.jl:371
while loading /home/colin/data/hog/train2.jl, in expression starting on line 15

However there seems to be some confusion over sources of data for this tutorial addressed in other issues. The process stops with the first non_human image, which in my case is 1.jpg and is a 65x129 image of a brick wall with a barred window in top right quadrant. Anyone else find the same thing?

@zygmuntszpak
Copy link
Member

I'm surprised to hear that you are getting a 65 x 129 image. Did you try load the image using a different image editor to confirm the size? Might be worth validating to be sure its not a bug in Julia. Are all of the non-human images likes that? You could, of course, just re-size the images to be of size 64 by 128 as a workaround.

@colbec
Copy link

colbec commented Mar 18, 2018

@zygmuntszpak Yes I opened in a couple other applications and all confirmed the odd image size. Resizing was the solution, now the tutorial runs to completion with the somewhat surprising result of 100% accuracy.

@davidbp
Copy link
Contributor Author

davidbp commented Mar 19, 2018

I can verify that most of the tutorial works if you Pkg.clone the repo.
There is a detail though...

In the code it says:

#Split the dataset into train and test set. Train set = 2500 images, Test set = 294 images.
random_perm = randperm(n)
train_ind = random_perm[1:2500]
test_ind = random_perm[2501:end]

Nevertheless my train set has 924 images not 2500 !

Another detail: I get all scores as 0 (this is weird) Therefore the object locations part of the tutorial do not work.

scores[scores.>0] = 0
object_locations = findlocalminima(scores)
0-element Array{CartesianIndex{2},1}

@colbec
Copy link

colbec commented Mar 19, 2018

Nevertheless my train set has 924 images not 2500 !

Hmm that is strange; the data looks ok to me:

julia> include("train2.jl")
[1]Accuracy: 100.00%
julia> size(data[:,train_ind])
(3780, 2500)
julia> size(data[:,test_ind])
(3780, 294)

@davidbp
Copy link
Contributor Author

davidbp commented Mar 20, 2018

@colbec where did you download the data? could you post the url here? thank you!

@colbec
Copy link

colbec commented Mar 20, 2018

@davidbp David, see your comment in the other issue at #44 (comment) ; you should find it leads to a non-human set of images as one component. The collection contains images with a number of different sizes and some of these are not compatible with the cell size of the HOG analysis. All I have done so far is to resize all of them to a standard 64x128 but other solutions might lead to a more accurate result.

@davidbp
Copy link
Contributor Author

davidbp commented Mar 20, 2018

Thank you for comment, I've read all comments from the two issues but I still don't see what data are you referring to. I could only find 2 links:

  • There is a link you posted that returns 404 Error.
  • There is another link zygmuntszpak posted. This link works and contains tar file with images from per00001.ppm to per00923.ppm. All images correspond to pedestrians and there are less than 1000 images (definetly not 2500).

@colbec
Copy link

colbec commented Mar 20, 2018

Your comment in the other issue refers to https://github.com/mbeyeler/opencv-machine-learning/tree/78f5f6ecfbbae3f61b378060d60641420331115c/notebooks/data/chapter6 ; see pedestrians_neg file.

@davidbp
Copy link
Contributor Author

davidbp commented Mar 20, 2018

Thank you for your clarification Nevertheless the positive set of examples in the link you just posted doesn't have 2500 examples. So I assume that from the 50 negative examples and from the 940 positive examples you have generated a train set containing 2500 examples... right?

@colbec
Copy link

colbec commented Mar 20, 2018

Oh I see, I must have obtained the positive examples from one of the other sources, and by luck ended up with an approximately right combination. I'm having a problem discovering where the data came from and will have to go back through my history to see which source it came from. I'll post back when I find it.

@colbec
Copy link

colbec commented Mar 20, 2018

@davidbp OK it looks like the positive data came from @zygmuntszpak suggestion of the Wayback machine at #44 (comment)

@davidbp
Copy link
Contributor Author

davidbp commented Mar 20, 2018

@colbec that data from @zygmuntszpak has 924 images. The same images as in the link you provide above (which I provided in another thread). Anyway thank you for commenting the issue.

@davidbp
Copy link
Contributor Author

davidbp commented Mar 20, 2018

I think we should

1 - Clarify exactly what is the data (where to download it)
2 - Update the notebook.
3 - Write in the readme of the package that it should be installed with Pkg.clone since the Pkg.add did not allow us to use the HOG.

Then close this thread once we have a notebook with "reproducible" results.

@colbec
Copy link

colbec commented Mar 20, 2018

@davidbp Yes you are right, evidently that is not the source, I will keep looking but am very puzzled where it might have come from - my browser history is not much help in this case. I just examined my not_humans directory and find that it contains 1870 items, which together with the 924 from humans totals 2794. When the tutorial takes the train set of 2500 this leaves 294 for the test set, given the count of files that I have. I did not do any image engineering to produce more examples.

@davidbp
Copy link
Contributor Author

davidbp commented May 13, 2018

I have redone the notebook from scratch changing some parts that didn't work.

https://github.com/davidbp/learn_julia/blob/master/JuliaImages/pedestrian_detection.ipynb

This notebook works with the data we already know where to get (we could even put it in a github repo since It is quite small). The negative samples I used are simply patches of the 50 negatives samples of the dataset we found.

I can close this issue anytime but it would be nice to merge/adapt this code that works.

Deepank308 added a commit to Deepank308/ImageFeatures.jl that referenced this issue Jan 6, 2019
The download link is now fixed for downloading pedestrian dataset as provided by @davidbp in JuliaImages#44.
The odd size of 65x129 is also fixed as reported by @colbec in JuliaImages#48.
@timholy
Copy link
Member

timholy commented Jan 6, 2019

Closed in #60

@timholy timholy closed this as completed Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants