Giter VIP home page Giter VIP logo

megadepth_tensorflow's Introduction

megadepth_tensorflow's People

Contributors

aaronjstewart avatar kkk324 avatar supernlogn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

megadepth_tensorflow's Issues

Always getting the same depth result when running tflite inference

I made the following steps to get a tflite model:

1. Froze session:
output_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(["module/div_1"] ) with tf.compat.v1.gfile.GFile("megadepth.pb", "wb") as f: f.write(output_graph_def.SerializeToString())

2. Converted inference graph to tflite:

`

def convert(): 
converter = tf.compat.v1.lite.TFLiteConverter.from_frozen_graph(
    graph_def_file='megadepth.pb',
    input_arrays=['Placeholder'],
    input_shapes={'Placeholder' : [1, 240, 320, 3]},
    output_arrays=['module/div_1']
)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_model = converter.convert()

with open('model.tflite', 'wb') as f:
    f.write(tflite_model)

`

3. Ran inference on Android using implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'

I used the model which includes pre and post processing. No matter what image I give the model, it always produces the exact same gradient grayscale image, very similar (or maybe the same) as reported here: zhengqili/MegaDepth#8
Screenshot 2020-11-17 at 11 23 25

You wrote that you successfully ran inference on both iOS and Android. What tflite version did you try it with?

CoreML model?

Is there any chance you can provide CoreML exports so we can test it on mobile devices? Thanks.

Full-resolution depthmaps: Errors with certain specific image sizes

I've been trying to apply inference_mega_tensorflow.py to my own images. It works well, until I try to generate full-resolution depth maps.

The error can be reproduced even with the stock docs/demo.jpg. I'm changing the following lines in the above file:

    input_height = 240
    input_width = 320

Changing this to 2316X3099 results in the following error:

  File "inference_mega_tensorflow.py", line 214, in <module>
    main()
  File "inference_mega_tensorflow.py", line 114, in main
    mega_out = build_mega_model(imag_pl)
  File "inference_mega_tensorflow.py", line 72, in build_mega_model
    prediction_1 = HourglassModel().fridaymodel(input_image_ph, is_training=False)
  File "/home/xxxx/EclipseWorkspace1/MegaDepth_TensorFlow/src/hourglass_mega_tf_resize_bilinear_tflayer_prepost.py", line 202, in fridaymodel
    conv2a = self.Channels4(conv1a_relu, is_training=is_training)
  File "/home/xxxx/EclipseWorkspace1/MegaDepth_TensorFlow/src/hourglass_mega_tf_resize_bilinear_tflayer_prepost.py", line 159, in Channels4
    conv4b = self.Channels3(conv3b, is_training=is_training)
  File "/home/xxxx/EclipseWorkspace1/MegaDepth_TensorFlow/src/hourglass_mega_tf_resize_bilinear_tflayer_prepost.py", line 134, in Channels3
    conv4b = self.Channels2(conv3b, is_training=is_training)
  File "/home/xxxx/EclipseWorkspace1/MegaDepth_TensorFlow/src/hourglass_mega_tf_resize_bilinear_tflayer_prepost.py", line 114, in Channels2
    conv4b = self.Channels1(conv3b, is_training=is_training)
  File "/home/xxxx/EclipseWorkspace1/MegaDepth_TensorFlow/src/hourglass_mega_tf_resize_bilinear_tflayer_prepost.py", line 95, in Channels1
    output = conv2a + uconv4b
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1181, in binary_op_wrapper
    raise e
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1165, in binary_op_wrapper
    return func(x, y, name=name)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/util/dispatch.py", line 206, in wrapper
    return target(*args, **kwargs)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1487, in _add_dispatch
    return gen_math_ops.add_v2(x, y, name=name)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 482, in add_v2
    "AddV2", x=x, y=y, name=name)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 750, in _apply_op_helper
    attrs=attr_protos, op_def=op_def)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3539, in _create_op_internal
    op_def=op_def)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2019, in __init__
    control_input_ops, op_def)
  File "/home/xxxx/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1859, in _create_c_op
    raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 289 and 288 for '{{node module/3/0/0/3/0/0/3/0/1/3/add}} = AddV2[T=DT_FLOAT](module/3/0/0/3/0/0/3/0/1/3/0/0/1/concat, module/3/0/0/3/0/0/3/0/1/3/0/1/4/resize/ResizeNearestNeighbor)' with input shapes: [1,289,387,256], [1,288,386,256].

Curiously, I only get this error for certain image sizes. For example, I find that 2304X3072 works fine, whereas 2316X3099 results in the above error.

Question

How do I remove the need to specify image size, so that I automatically get a depthmap in the exact same resolution as the input image?

Upload .pbtxt file

Hi,

Thank you very much for your work. Is that possible for you to upload .pbtxt file as well? Since tensorflow have changed to 2.0 and our class use tf 2.0 as well. I just need that to convert your pretrained model in tf2.0. Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.