shicai / MobileNet-Caffe

Caffe Implementation of Google's MobileNets (v1 and v2)
BSD 3-Clause "New" or "Revised" License
1.26k stars 708 forks source link

Wrong predictions after fine-tuning the mobilenetv2 model #91

Closed neerajasjawali closed 12 months ago

neerajasjawali commented 1 year ago

Hi @shicai

I have implemented fine-tuning on mobilenetv2 model for 6 fruits classes. While testing the model I am getting wrong predictions. Generated the train.txt and val.txt files, modified the .prototxt file, yet the trained model is not working as expected.

Contents of the .prototxt file

layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.017
    mirror: true
    crop_size: 224
    mean_value: [103.94,116.78,123.68]
  }
  image_data_param {
    source: "input/train.txt"
    batch_size: 8 # your batch size
    new_height: 256
    new_width: 256
    root_folder: ""
  }
}
layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.017
    mirror: true
    crop_size: 224
    mean_value: [103.94,116.78,123.68]
  }
  image_data_param {
    source: "input/val.txt"
    batch_size: 8 # your batch size
    new_height: 256
    new_width: 256
    root_folder: ""
  }
}
layer {
  name: "fc7_fruits"
  type: "Convolution"
  bottom: "pool6"
  top: "fc7_fruits"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 6
    kernel_size: 1
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "fc7_fruits"
  bottom: "label"
  top: "loss"
}
layer {
  name: "top1/acc"
  type: "Accuracy"
  bottom: "fc7_fruits"
  bottom: "label"
  top: "top1/acc"
  include {
    phase: TEST
  }
}

solver.prototxt

test_iter: 40 #not subject to iter_size
test_interval: 10
base_lr: 0.0001
display: 20
max_iter: 1000
iter_size: 16 #global batch size = batch_size * iter_size
lr_policy: "poly"
power: 1.0 #linearly decrease LR
momentum: 0.9
weight_decay: 0.0002
snapshot: 100
snapshot_prefix: "fruits_train"
solver_mode: GPU
random_seed: 42
net: "train.prototxt"
test_initialization: true
average_loss: 40

Could you please help me understand if any mistakes or missteps on my end?

Thanks in advance

changan1tao commented 1 year ago

您好,您的邮件我已收到

lcj820 commented 1 year ago

我已收到你的邮件,谢谢

changan1tao commented 12 months ago

您好,您的邮件我已收到

lcj820 commented 12 months ago

我已收到你的邮件,谢谢