dimroc / count

An experiment with crowd counting. Trains a keras model in python for use with Rails and iOS CoreML.
http://blog.dimroc.com/2017/11/19/counting-crowds-and-lines/
53 stars 13 forks source link

Running Steps #8

Open Akhtar303 opened 5 years ago

Akhtar303 commented 5 years ago

Hi @dimroc ,@thoughtmerchant and @whatrocks , I want to use your code but I don't need to use your Interface of your project. but I want to use your ML part with simple demo i.e give video frame or only image to count number of people in line.i so kindly guide me some step of your project to complete my job. Thanks

dimroc commented 5 years ago

Hey there @Akhtar303, you can run the count model against a single frame with the python manage.py predict command. Documentation and help is lacking, so check out the source: https://github.com/dimroc/count/blob/master/ml/crowdcount/management/commands/predict.py#L12-L16

cd ml
python manage.py # lists all available ML commands

# python manage.py predict --image <path to image> --just-predictions
python manage.py predict --image data/shakecam/shakeshack-1500925619.jpg --just-predictions 

There are two big considerations however:

  1. You'll need to install the dependencies, which isn't always straightforward:
    • cd ml
    • conda-env create -f environment.yml or conda env update -f=environment.yml
    • The environment may have experienced decay or erosion, in that dependencies may have changed or been deprecated.
  2. The prediction model is tailored to the shakecam and won't give a good prediction for a random video frame with different camera position and person layout.

I doubt this will be as straightforward as my todo list implies above :/. Good luck.

Akhtar303 commented 5 years ago

python manage.py --image data/shakecam/shakeshack-1500925619.jpg --just-predictions 
``
Thanks @dimroc 
when I have run file it doesn't recognize the image flag Unknown command: --image
python manage.py --image data/shakecam/shakeshack-1500925619.jpg --just-predictions 
so kindly help me
philkim72 commented 5 years ago

Hi @dimroc - I was hoping to be able to access your set of annotated shackcam images. Is it possible to share?

dimroc commented 5 years ago

@Akhtar303 I missed a word

python manage.py predict --image data/shakecam/shakeshack-1500925619.jpg --just-predictions 

Please use python manage.py help to see all commands. This is a standard django command.

dimroc commented 5 years ago

@philkim72 The annotations are in json and can be found in the repo here: https://github.com/dimroc/count/tree/master/ml/data/annotations

If you're looking to generate an image like the one below, you'll need to run one of the commands above (I think python manage.py preview_label or python manage.py predict) image

philkim72 commented 5 years ago

@dimroc I have successfully annotated the images following your instructions. One quick question. There is a file called ignorables.csv. It seems you are ignoring some pictures because there are some counting issues such as umbrellas. But there are other images you ignore that seem perfectly fine. Can you explain what your criteria was for ignoring certain images in your training data set?

dimroc commented 5 years ago

I think I just thought the annotations were wrong. If there’s more to it, please feel free to remind me, it’s been a while.

philkim72 commented 5 years ago

Thanks. I can't find any common pattern at this point, but I will just ignore the entire list for now. By the way, I noticed that recently they put a tent at the front of the line. I'm assuming part of it has to do with it's rainy season right now, but i'm afraid that it might be a permanent thing. Do you have any thoughts about how to get around this issue?

dimroc commented 5 years ago

At this time no. Many crowd counting models and algorithms rely on creating a density map of heads, as shown below. If we can't see the head, we're in trouble. But feel free to do some further reading here to see if someone else has a solution: https://github.com/gjy3035/Awesome-Crowd-Counting

image

Akhtar303 commented 5 years ago

python manage.py predict --image data/shakecam/shakeshack-1500925619.jpg --just-predictions

Thanks @dimroc for reply when I run python3 manage.py predict --image data/shakecam/shakeshack-1500925619.jpg --just-predictions it genrate error because it is unable to read json file from mall.json and I have given absolute path ='/home/akhtar/crowd_counting/count/ml/data/annotations/mall.json'

Error:"/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This error genrate by this line dic.update(json.load(infile)) in regresion.py

after that I want to read simple mall.json it genrate same error import json with open('/home/akhtar/crowd_counting/count/ml/data/annotations/mall.json') as json_file: data = json.load(json_file)

Error:ile "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thanks

ramondebruyn commented 3 years ago

Hi @dimroc,

Thanks so much for this incredible code and example!

I've been playing around with the models and code for the past weeks or so, and am having some trouble. 2 quick questions: 1) When I open the iOS or MacOS example apps, I get various errors after trying to install the dependancies - most of the errors are related to dependancies. Do you by any chance have a more recent implementation example in iOS? 2) In playing around with the HundredsPredictor.mlmodel in a separate app (copying the actual mlmodel in the fresh app), I'm able to get an output form the model, but it's in the form of a MultiArray (Double 1 x 168 x 225). The only output fields I have access to are: "requestRevision", "confidence" and "timeRange", but the rest is inaccessible. How do I go about extracting the actual estimated count from the image that I passed into the HundredsPredictor?

[<VNCoreMLFeatureValueObservation: 0x2801a75a0> A94E606F-856D-4D56-846D-B5E8A513EAAE requestRevision=1 confidence=1.000000 timeRange={{0/1 = 0.000}, {0/1 = 0.000}} "density_map" - "MultiArray : Double 1 × 168 × 225 array" (1.000000)]

Thanks again for the amazing work!

Best, Ramon

(PS. I'm using Xcode 12.4 & iOS 14.4 to run the above packages.)

dimroc commented 3 years ago

Hey there Ramon, glad you’re enjoying the repo. I’m years removed from this code so will do my best to provide insight.

  1. Unfortunately no, I don’t have a more recent implementation of the iOS app.
  2. I think I simply summed the multi array. Ignore the first (1x) dimension. The code to do that should be in the repo, since both the iOS app and the playground show a hundreds prediction.

Hope this helps

On Wed, Feb 24, 2021 at 9:56 PM ramondebruyn notifications@github.com wrote:

Hi @dimroc https://github.com/dimroc,

Thanks so much for this incredible code and example!

I've been playing around with the models and code for the past weeks or so, and am having some trouble. 2 quick questions:

  1. When I open the iOS or MacOS example apps, I get various errors after trying to install the dependancies - most of the errors are related to dependancies. Do you by any chance have a more recent implementation example in iOS?
  2. In playing around with the HundredsPredictor.mlmodel in a separate app (copying the actual mlmodel in the fresh app), I'm able to get an output form the model, but it's in the form of a MultiArray (Double 1 x 168 x 225). The only output fields I have access to are: "requestRevision", "confidence" and "timeRange", but the rest is inaccessible. How do I go about extracting the actual estimated count from the image that I passed into the HundredsPredictor?

[<VNCoreMLFeatureValueObservation: 0x2801a75a0> A94E606F-856D-4D56-846D-B5E8A513EAAE requestRevision=1 confidence=1.000000 timeRange={{0/1 = 0.000}, {0/1 = 0.000}} "density_map" - "MultiArray : Double 1 × 168 × 225 array" (1.000000)]

Thanks again for the amazing work!

Best, Ramon

(PS. I'm using Xcode 12.4 & iOS 14.4 to run the above packages.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dimroc/count/issues/8#issuecomment-785538785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3B4L2SVJIO5D2YSVLHPTTAW34NANCNFSM4GY53I4A .

--

  • Sent from my iPhone
ramondebruyn commented 3 years ago

Thanks for the response, @dimroc. I'll keep digging.