GithubHelp home page GithubHelp logo

Comments (7)

nonononentity avatar nonononentity commented on May 2, 2024

233, model 1 has no error just now after I change the feature map size.
And the final res of model is accurate.

2022-06-15 09-52-41屏幕截图
2022-06-15 09-53-07屏幕截图

from tinyneuralnetwork.

peterjc123 avatar peterjc123 commented on May 2, 2024

@nonononentity Would you please share the models in TorchScript format, which can be exported via the following code? Please also tell us the shape of the input tensors.

script = torch.jit.trace(model, dummy_input)
torch.jit.save(script, 'model.pt')

from tinyneuralnetwork.

nonononentity avatar nonononentity commented on May 2, 2024

I have changed my builder script, please try my history version.
model_1.zip

This model should be same as "model_1" above, which raise up problems in node 'input0.3' in "NO_OPTIM" tflite file.

from tinyneuralnetwork.

peterjc123 avatar peterjc123 commented on May 2, 2024

This issue can be reproduced with the following code.

>>> import torch
>>> t = torch.randn(1, 3, 8, 22)
>>> pt = torch.nn.functional.interpolate(t, (15, 43), None, 'nearest')
>>> t_i = t.permute(0, 2,3,1)
>>> import tensorflow as tf
>>> t_o = tf.compat.v1.image.resize_nearest_neighbor(t_i.numpy(), (15, 43), half_pixel_centers=True)
>>> tt = torch.from_numpy(t_o.numpy()).permute(0, 3, 1, 2)
>>> (pt - tt).abs().max()
tensor(5.4481)
>>> (pt - tt).abs().min()
tensor(0.)
>>> torch.nonzero((pt - tt).abs())
tensor([[ 0,  0,  0, 21],
        [ 0,  0,  0, 23],
        [ 0,  0,  0, 25],
        ...,
        [ 0,  2, 14, 37],
        [ 0,  2, 14, 39],
        [ 0,  2, 14, 41]])

Surprisingly, by setting half_pixel_centers=False, the results seem matched. We will take a further look soon.

>>> t_o = tf.compat.v1.image.resize_nearest_neighbor(t_i.numpy(), (15, 43), half_pixel_centers=False)
>>> tt = torch.from_numpy(t_o.numpy()).permute(0, 3, 1, 2)
>>> torch.nonzero((pt - tt).abs())
tensor([], size=(0, 4), dtype=torch.int64)

from tinyneuralnetwork.

peterjc123 avatar peterjc123 commented on May 2, 2024

@nonononentity Should be fixed via 9e8636a. Would you please try again?

from tinyneuralnetwork.

nonononentity avatar nonononentity commented on May 2, 2024

Thank you. I can't find the details of param half_pixel-centers in tensorflow's doc. And I find an old blog which said the calculation of resizeNearest would be same as resizeBilinear when half_pixel_center=False.
In fact, I need to resize a feature map used to detect mono depth. The near objects and far objects are separated in distance in groundtruth. So I think resizeNearest maybe better.

I will try it again with resolution (15, 43) feature map after I integrate these bad code. 23333

from tinyneuralnetwork.

peterjc123 avatar peterjc123 commented on May 2, 2024

Local experiment results shows the pr fixed the issue at my side, so I will close the issue for now. If it is not the case, please feel free to reopen it by replying to it.

from tinyneuralnetwork.

Related Issues (20)

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.