Azure-Samples / Custom-vision-service-iot-edge-raspberry-pi

Sample showing how to deploy a AI model from the Custom Vision service to a Raspberry Pi 3 device using Azure IoT Edge
MIT License
186 stars 135 forks source link

Custom Vision has changed input layer size #39

Closed nanowireUK closed 5 years ago

nanowireUK commented 5 years ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [X] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Train and export a new model in Custom Vision Try to run this model using the ImageClassifer module

Any log messages given by the failure

Expected/desired behavior

Works as before

Versions

Mention any other details that might be useful

New models exported as Tensorflow .pb files appear to know have an input layer size of 224 whereas previously this was 227. In this code the 227 is hardcoded in so newly exported models have stopped working.

Have this issue fixed in my code and will create a pull request. Fix is to extend initialize() to use the shape of the input layer:

def initialize():
    print('Loading model...',end=''),
    with tf.gfile.GFile(filename, 'rb') as f:
        graph_def.ParseFromString(f.read())
        tf.import_graph_def(graph_def, name='')
        input_tensor = tf.get_default_graph().get_tensor_by_name("Placeholder:0")
        network_input_size = int(input_tensor.get_shape()[1])
        print("Adjusted network input size to " + str(network_input_size))
    print('Success!')
    print('Loading labels...', end='')
    with open(labels_filename, 'rt') as lf:
        for l in lf:
            l = l[:-1]
            labels.append(l)
    print(len(labels), 'found. Success!')

Thanks! We'll be in touch soon.

nanowireUK commented 5 years ago

this is solved with recent commit