Code Monkey home page Code Monkey logo

Comments (11)

pengdengke avatar pengdengke commented on August 20, 2024 2

@leopku I also encountered the same problem, do you use readImg.ResizeArea(image.Size{Height:224, Width:224})

Yes.

Thank you, it helped me a lot.
Thanks also to the author

from tfgo.

galeone avatar galeone commented on August 20, 2024

You need to add the batch dimension to the input tensor, in order to correctly feed the model with a (1, 573,860,3) shaped tensor

You can use tg.Batchify more or less in this way (code not tested I'm not able to run it right now, I'm sorry)

img := tg.Batchify(scope, []tf.Output{image.Read(scope, "/tmp/test.jpeg", 3)})

from tfgo.

leopku avatar leopku commented on August 20, 2024

@galeone Big Thanks.

This time error was panic: Can not squeeze dim[1], expected a dimension of 1, got 44

core code

		img := tg.Batchify(scope, []tf.Output{image.Read(scope, "/tmp/a72.jpg", 3).Value()})
		input := tg.Exec(scope, []tf.Output{img}, nil, &tf.SessionOptions{})

		results := model.Exec(
			[]tf.Output{model.Op("StatefulPartitionedCall", 0)},
			map[tf.Output]*tf.Tensor{model.Op("serving_default_input", 0): input[0]},
		)
		log.Debug().Interface("results", results[0].Value()).Msg("")

from tfgo.

galeone avatar galeone commented on August 20, 2024

I don't know from where the 44 came from - is it an input dimension?

Can you show me the shape of img after the batchify call?

from tfgo.

leopku avatar leopku commented on August 20, 2024

The shape was [1, ?, ?, 3].

Maybe 44 came from input dimension.

I wrote the input dimension into a file. Now I'm analyzing it.

from tfgo.

leopku avatar leopku commented on August 20, 2024

Finally fixed by comparing codes between which using tensorflow official go package.

from tfgo.

galeone avatar galeone commented on August 20, 2024

Out of curiosity - can you show me how you fixed it?

from tfgo.

leopku avatar leopku commented on August 20, 2024

Out of curiosity - can you show me how you fixed it?

I forgot to resize the image 😭 . Resizing the image before batchify can fix it.

This tfgo library is so cool. I really like it.

Finally, thank you for your reply and this amazing library.

from tfgo.

galeone avatar galeone commented on August 20, 2024

Thank you for the kind words!! 😃

from tfgo.

pengdengke avatar pengdengke commented on August 20, 2024

@leopku I also encountered the same problem, do you use readImg.ResizeArea(image.Size{Height:224, Width:224})

from tfgo.

leopku avatar leopku commented on August 20, 2024

@leopku I also encountered the same problem, do you use readImg.ResizeArea(image.Size{Height:224, Width:224})

Yes.

from tfgo.

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.