Coder Social home page Coder Social logo

how to run batch inference about aster HOT 4 OPEN

bgshih avatar bgshih commented on August 17, 2024
how to run batch inference

from aster.

Comments (4)

13070151771 avatar 13070151771 commented on August 17, 2024

哈哈我也想知道

from aster.

cbasavaraj avatar cbasavaraj commented on August 17, 2024

I am trying to do this myself, but I get a tf error:

            self.aster_input_images = tf.placeholder(
                dtype='uint8',
                shape=[None, None, None, 3])
            resized_image_tensors = tf.image.resize_images(
                tf.to_float(self.aster_input_images),
                [64, 256])

            aster_model_config, _, _ = get_aster_configs()
            aster = model_builder.build(aster_model_config, is_training=False)

            predictions_dict = aster.predict(resized_image_tensors)
            recognitions = aster.postprocess(predictions_dict)

The error is on this line:
predictions_dict = aster.predict(resized_image_tensors)

and as follows:
ValueError: The last dimension of the inputs toDenseshould be defined. FoundNone.

from aster.

dsandii avatar dsandii commented on August 17, 2024

@cbasavaraj I'm running into the same problem. Were you able to resolve it?

from aster.

cbasavaraj avatar cbasavaraj commented on August 17, 2024

Hi, sorry for the late response, was traveling. I haven't looked at this code in over eight months, but looks like I finally ran it one image at a time. Pasting the relevant code here. Hope it helps!

Defining:
`

        graph_aster = tf.Graph()
        with graph_aster.as_default():

            print('Defining ASTER...')
            self.aster_input_image = tf.placeholder(
                dtype='uint8',
                shape=[None, None, 3])
            resized_image_tensor = tf.image.resize_images(
                tf.to_float(self.aster_input_image),
                [64, 256])

            aster_model_config, _, _ = get_aster_configs()
            aster = model_builder.build(aster_model_config, is_training=False)

            predictions_dict = aster.predict(tf.expand_dims(resized_image_tensor, 0))
            recognitions = aster.postprocess(predictions_dict)

            recognition_text = recognitions['text'][0]
            recognition_score = recognitions['scores'][0]
            control_points = predictions_dict['control_points'],
            rectified_images = predictions_dict['rectified_images']

            self.aster_fetches = {
                'recognition_text': recognition_text,
                'recognition_score': recognition_score,
                'control_points': control_points,
                'rectified_images': rectified_images,
            }

            print('Loading ASTER from {}'.format(aster_model_path))

            self.tf_session_aster = tf.Session(config=tf_config)
            self.tf_session_aster.run([tf.global_variables_initializer(),
                                       tf.local_variables_initializer(),
                                       tf.tables_initializer()])

`

Inference:
`

        for roi in rois:
            aster_fetches = self.tf_session_aster.run(self.aster_fetches,
                                                      feed_dict={self.aster_input_image: roi})
            word = aster_fetches['recognition_text'].decode('utf-8')
            words.append(word)
            prob = np.exp(aster_fetches['recognition_score'])
            probs.append(prob)
            roir = aster_fetches['rectified_images'][0]
            roir = (128 * (roir + 1.)).astype(np.uint8)
            roirs.append(roir)

`

from aster.

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.