sacmehta / EdgeNets

This repository contains the source code of our work on designing efficient CNNs for computer vision
MIT License
412 stars 82 forks source link

Is it possible to use DiCENet train a regression model #12

Closed w11m closed 5 years ago

w11m commented 5 years ago

thanks for the great work i would like to use the idea of DiceNet on a custom dataset. And i'm new to DL and pytorch can you give me some idea how to make it?

Thank you:)

w11m commented 5 years ago

And also my data is a non-3 channel (70 channel)

w11m commented 5 years ago

I edited the program for own dataloader and try to change all the arguments(channel,width,height) in the code

but still get the error message below

/home/tan/William/DiCENeT/EdgeNets/nn_layers/dice.py:73: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if height != self.height:
/home/tan/William/DiCENeT/EdgeNets/nn_layers/dice.py:83: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if height != h_wise_height:
/home/tan/William/DiCENeT/EdgeNets/nn_layers/dice.py:91: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if width != self.width:
/home/tan/William/DiCENeT/EdgeNets/nn_layers/dice.py:100: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if width != w_wise_width:
Traceback (most recent call last):
  File "train_classification.py", line 346, in <module>
    main(args)
  File "train_classification.py", line 83, in main
    flops = compute_flops(model)
  File "/home/tan/William/DiCENeT/EdgeNets/utilities/utils.py", line 64, in compute_flops
    _ = model(input)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/tan/William/DiCENeT/EdgeNets/model/classification/dicenet.py", line 169, in forward
    x = self.level1(x)  # 112
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/tan/William/DiCENeT/EdgeNets/nn_layers/cnn_utils.py", line 54, in forward
    return self.cbr(x)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/container.py", line 92, in forward
    input = module(input)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/conv.py", line 343, in forward
    return self.conv2d_forward(input, self.weight)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/conv.py", line 340, in conv2d_forward
    self.padding, self.dilation, self.groups)
**RuntimeError: Given groups=1, weight of size 16 70 3 3, expected input[1, 3, 224, 224] to have 70 channels, but got 3 channels instead**

the data size is 96 x 96 x 70 (W x H x C)

w11m commented 5 years ago

I think I already fix the error above the error caused by the code in /utilities/utils.py

input = input if input is not None else torch.Tensor(1, 70, 96, 96)

def compute_flops(model, input=None):
    from utilities.flops_compute import add_flops_counting_methods
    input = input if input is not None else torch.Tensor(1, 70, 96, 96)

    model = add_flops_counting_methods(model)
    model.eval()
    model.start_flops_count()

    _ = model(input)

    flops = model.compute_average_flops_cost()  # + (model.classifier.in_features * model.classifier.out_features)
    flops = flops / 1e6 / 2
    return flops