chaosmail / caffejs

Run Caffe models in the browser using ConvNetJS
https://chaosmail.github.io/caffejs/
MIT License
118 stars 21 forks source link

when i use caffe net trained by myself,it run error! #1

Closed shenyuhit closed 7 years ago

shenyuhit commented 7 years ago

image

I trained a model using caffenet by caffe 。 and i try to use caffejs to predict ,it can run,but the result is error! Which step may error?

chaosmail commented 7 years ago

Hi @shenyuhit thanks for reporting this!

Which model are you using, and can you share your trained model with me so I can reproduce the error?

Best, Christoph

shenyuhit commented 7 years ago

@chaosmail I can share my model to you! Can you provide your email address? Thanks for help!

chaosmail commented 7 years ago

Sure, office [at] chaosmail [dot] at

shenyuhit commented 7 years ago

@chaosmail i have send the model to you ! My gmai is shenyuhit@gmail.com , If necessary, we can contact by google hangouts.

chaosmail commented 7 years ago

Hi @shenyuhit thanks I received your mail. The first problem i spot is in the prototxt file.

My (ancient) custom Parser parsing the PROTOTXT file is very fragile and cannot parse the following properly

name: "CaffeNet"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }
}

it needs to be in this format (see https://github.com/chaosmail/caffejs/blob/master/docs/assets/models/bvlc_alexnet/deploy.prototxt)

name: "CaffeNet"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param {
    shape {
      dim: 10
      dim: 3
      dim: 227
      dim: 227
    }
  }
}

Note that i added newlines and indents for the shape property, and removed the : after the shape key.

However, I already included a 3rd lib Prototxt Parser (also used for parsing protomean) in the project and I should use it in the samples.

Could you try it again with the modified prototxt?

Best, Christoph

shenyuhit commented 7 years ago

@chaosmail I found this problem before,and I changed the file ,and the program can run. When i send the email,i forgot to modify the prototxt. The problem is " it can run,but the result is error! "

chaosmail commented 7 years ago

Hi @shenyuhit for me the network is doing the forward pass, however the result for different input images is always the first class (so most likely it is wrong).

I found out, that the mean file you provided has the dimensions 3x256x256 while the input requires 3x227x227. this is a problem in CaffeJs because we only do one transformation (to 3x227x227) in the imagenet demo. Could you compute and send me a train mean with the target dimensions - or for simplification could you compute only RGB mean?

shenyuhit commented 7 years ago

@chaosmail I noticed this problem you said before, so for my predict, i use the "var mean = [104.0, 116.0, 122.0];" default set in your code..I compute the RGB mean , the value is "var mean = [100.254, 114.454, 121.706];"

shenyuhit commented 7 years ago

@chaosmail I view the code in caffe. The mean order is BGR by the opencv api