wangzhecheng / DeepSolar

Nationwide houseshold-level solar panel identification with deep learning
MIT License
247 stars 73 forks source link

Segmentation before Classification? #10

Closed rymanso closed 5 years ago

rymanso commented 5 years ago

Can I train the segmentation branch without training the classification branch? I only require the segmentation part of the script. When I try to do so with two layers false I get the following error:

python3 train_segmentation.py --two_layers=False Training set built. Size: 366467 Traceback (most recent call last): File "/home/user/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1659, in _create_c_op c_op = c_api.TF_FinishOperation(op_desc) tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 4 but is rank 2 for 'conv_aux_1/Conv2D' (op: 'Conv2D') with input shapes: [64,2], [3,3,288,512].

My package versions: numpy 1.16.3 tensorflow 1.13.1 (required me to change some paths when creating the saver in train_classification.py) scikit-image 0.15.0 (compatible with numpy 1.16.x unlike issue #7 ) pandas 0.23.4

I know these aren't the versions listed in requirements.txt, though I'm currently changing the files to be compatible with python 3.6. This may be the cause for the error, although I doubt this is the case as I have made changes to all dependencies so that they are compatible. And I don't understand why I have less elements in my input matrix just as a result of changing version.

Changes I have made to make it compatible:

e.g: from open('train_set_list', 'r') to open('train_set_list.pickle', 'rb')

to:

 # Create a saver.
        code_to_checkpoint_variable_map = {var.op.name: var for var in tf.all_variables()}
        for code_variable_name, checkpoint_variable_name in {
            "CrossEntropyLoss/value/avg": "tower_0/tower_0/CrossEntropyLoss/value/avg",
            "aux_loss/value/avg": "tower_0/tower_0/aux_loss/value/avg",
            "total_loss/avg": "tower_0/tower_0/total_loss/avg",
        }.items():
            code_to_checkpoint_variable_map[checkpoint_variable_name] = code_to_checkpoint_variable_map[
                code_variable_name]
            del code_to_checkpoint_variable_map[code_variable_name]

            saver = tf.train.Saver(code_to_checkpoint_variable_map)

Any help advice would be much appreciated, if I get this working I'll be happy to post a python 3 compatible version of this on github.

rymanso commented 5 years ago

Turns out i was using slim and inception_model.py from the library as opposed to the one provided

erikrubinov commented 2 years ago

@rymanso how did you use the imported inception model.py? It says that inception and inception.slim is not defined.