Coder Social home page Coder Social logo

Comments (2)

lreiher avatar lreiher commented on July 25, 2024

Hi, have you actually tried this and noticed a performance difference? If so, feel free to propose a PR with some information on what speed-up this gives on your system.

from cam2bev.

lreiher avatar lreiher commented on July 25, 2024

I have tried to swap the order of the pipeline calls, i.e. batch first and then map, by adjusting the mapped parse_sample function like so:

# build dataset pipeline parsing functions
def parse_sample(batched_input_files, batched_label_file):
    # parse and process input images

    # define unbatched parsing operations
    def parse_input(i):
        i = utils.load_image_op(i)
        i = utils.resize_image_op(i, image_shape_original_input, conf.image_shape, interpolation=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
        i = utils.one_hot_encode_image_op(i, conf.one_hot_palette_input)
        return i
    def parse_label(l):
        l = utils.load_image_op(l)
        l = utils.resize_image_op(l, image_shape_original_label, conf.image_shape, interpolation=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
        l = utils.one_hot_encode_image_op(l, conf.one_hot_palette_label)
        return l

    # parse and process input images
    inputs = []
    for inp in batched_input_files:
        inputs.append(tf.map_fn(parse_input, inp, fn_output_signature=tf.float32))
    inputs = inputs[0] if n_inputs == 1 else tuple(inputs)

    # parse and process label image
    label = tf.map_fn(parse_label, batched_label_file, fn_output_signature=tf.float32)

    return inputs, label

I did not find a way to vectorize the parsing across the entire batch. Vectorization is why the linked TensorFlow doc recommends batch first, then map. Without vectorization, this version actually had a worse runtime than before. My runtimes are included for reference:

  • config.1_FRLR.unetxst.yml
    • max-samples-training: 1000
    • max-samples-validation: 100
    • epochs: 20
    • save_interval: 10
  • GPU: RTX 3090
  • before: 16m 40s
  • after: 18m 30s

@bastilam: I propose to close the issue. MRs with documented runtime improvements are still happily accepted.

from cam2bev.

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.