Giter Site home page Giter Site logo

Comments (14)

beniz avatar beniz commented on August 27, 2024

Let me understand, you are trying to use the Caffe model from gillevi with dd, is that correct ?

I should be able to help, but more information is needed: all prototxt files typically and service + train API calls so that I can reproduce.

from deepdetect.

Qwasser avatar Qwasser commented on August 27, 2024

Yes, I am trying to use pretrained caffe model. It can be downloaded from here http://www.openu.ac.il/home/hassner/projects/cnn_agegender/cnn_age_gender_models_and_data.0.0.2.zip
To use the model I created "models/age" folder and put there deploy.prototxt (renamed deploy_age) and age.caffemodel files from the archive. Then I had created service using following code:

model = {'repository': '/home/ubuntu/models/age''}
parameters_input = {'connector':'image',
                            'width': 256,
                            'height': 256}
parameters_mllib = {'nclasses': 8}
parameters_output = {}

dd.put_service("age",
                       model,
                       "age classification",
                       'caffe',
                       parameters_input,
                       parameters_mllib,
                       parameters_output)

and the query is

curl -X POST "http://localhost:8080/predict" -d "{\"service\":\"age\",\"parameters\":{\"input\":{\"width\":256,\"height\":256},\"output\":{\"best\":3}},\"data\":[\"http://i.ytimg.com/vi/0vxOhd4qlnA/maxresdefault.jpg\"]}"

I think the problem is in deploy.prototxt and it should be converted somehow

from deepdetect.

beniz avatar beniz commented on August 27, 2024

Yes you need a memorydata layer at the top, this is so dd can pass data to the net. Look at the deploy file from templates/caffe/googlenet as an example. I will try to reproduce as well on my spare time, but please let me know how it goes.

from deepdetect.

Qwasser avatar Qwasser commented on August 27, 2024

Added following text to deploy.prototxt:

layers  {
  name: "caffenet"
  type: MEMORY_DATA
  top: "data"
  top: "label"
  memory_data_param {
    batch_size: 32
    channels: 3
    height: 256
    width: 256
  }
}

And everything worked :) Should it be in the documentation?

from deepdetect.

beniz avatar beniz commented on August 27, 2024

Ah got it to work in parallel to you. The key is to convert the Caffe model from the old format to the new one, and then update the deploy.prototxt file as well.

I've put a model tarball for the 8 classes age model here: http://www.deepdetect.com/models/age_model.tar.bz2
It is ready to use, though I can't report on the accuracy.

It could be added to the 'model' page http://www.deepdetect.com/applications/model/

from deepdetect.

Qwasser avatar Qwasser commented on August 27, 2024

Have you run into a trouble mean.binaryproto has incorrect dimensions?

from deepdetect.

beniz avatar beniz commented on August 27, 2024

I believe dimension is 227x227.

from deepdetect.

beniz avatar beniz commented on August 27, 2024

Btw, the predict call does not yet read the mean.binaryproto file. I will commit this shortly. From my short tests, it does affect the results significantly on this dataset.

from deepdetect.

beniz avatar beniz commented on August 27, 2024

Do you know what the age classes correspond to by any chance ? (0 to what range, etc..). Thanks.

OK. got it, put a file named corresp.txt in your model repository with the following in it:

0 0_2
1 4_6
2 8_13
3 15_20
4 25_32
5 38_43
6 48_53
7 60+

This is deducted from http://www.openu.ac.il/home/hassner/projects/cnn_agegender/CNN_AgeGenderEstimation.pdf and I may be wrong.

from deepdetect.

Qwasser avatar Qwasser commented on August 27, 2024

Yes, I just wanted to send them to you. I copied classes from notebook that comes with modela and they are the same as in your list.

from deepdetect.

beniz avatar beniz commented on August 27, 2024

OK good! I was just surprised that the example they give in their tarball, example_image.jpg seems to be reported as 60+ (0.53) and 0_2 (0.35). My own picture however is unfortunately not reported as younger...

from deepdetect.

Qwasser avatar Qwasser commented on August 27, 2024

Have you tried it in notebook from archive? Works fine there (even without mean substraction).

from deepdetect.

beniz avatar beniz commented on August 27, 2024

Somehow it works better for me without the mean substraction. I've investigated and failed to understand why. It's possible the mean.binaryproto is not in the exact same format as the ones produced by the Caffe compute_mean. The Caffe classification.cpp example uses a planar 32-bit float BGR or grayscale format.
Closing this since it appears to be working fine with dd anyways, can be reopened if the mean file issue is a problem in practice.

from deepdetect.

beniz avatar beniz commented on August 27, 2024

Age model added to http://www.deepdetect.com/applications/model/

from deepdetect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.