Giter VIP home page Giter VIP logo

pspnet_tf2's Introduction

PSPNet Tensorflow 2

Keras Pyramid Scene Parsing Network ported to tensorflow 2 from keras/tf_1.13.

Dependencies

  • Tensorflow 2 (tensorflow / tensorflow-gpu / tensorflow-cpu)
  • OpenCV (opencv-python / opencv-contrib-python)

Pretrained weights

Pretrained weights can be downloaded here:

H5 Weights Architecture Numpy Weights
pspnet50_ade20k.h5 pspnet50_ade20k.json pspnet50_ade20k.npy
pspnet101_cityscapes.h5 pspnet101_cityscapes.json pspnet101_cityscapes.npy
pspnet101_voc2012.h5 pspnet101_voc2012.json pspnet101_voc2012.npy

Download weights in

  • .h5 and .json format and place them at weights/keras or
  • .npy and place them at weights/npy

Find example notebook which demonstrates save and load.

Usage:

# python pspnet.py -m <model> -i <input_image>  -o <output_path> [-other_arguments]
python pspnet.py -m pspnet101_cityscapes -i example_images/cityscapes.jpg -o example_results/cityscapes.jpg -s -ms -f
python pspnet.py -m pspnet101_voc2012 -i example_images/pascal_voc.jpg -o example_results/pascal_voc.jpg -s -ms -f
python pspnet.py -m pspnet50_ade20k -i example_images/ade20k.jpg -o example_results/ade20k.jpg -s -ms -f

List of arguments:

 -m --model        - which model to use: 'pspnet50_ade20k', 'pspnet101_cityscapes', 'pspnet101_voc2012'
    --id           - (int) GPU Device id. Default 0
 -s --sliding      - Use sliding window
 -f --flip         - Additional prediction of flipped image
 -ms --multi_scale - Predict on multiscale images

new Batch Predict on GPU, check source here

Keras results:

Input Segmented Blended Probe
Original New New New
Original New New New
Original New New New

Implementation

  • The interpolation layer is implemented as custom layer "Interp"
  • Forward step takes about ~1 sec on single image
  • Memory usage can be optimized with:
# before calling any of the tf functions
for gpu in tf.config.experimental.list_physical_devices('GPU'):
    tf.config.experimental.set_memory_growth(gpu, True)
    # if you want to restrict total memory you can try
    # tf.config.experimental.set_memory_growth(gpu, True)

pspnet_tf2's People

Contributors

davidgillsjo avatar jefequien avatar jmtatsch avatar mrlzla avatar petercheng00 avatar saravanabalagi avatar vladkryvoruchko avatar wassname avatar wcy940418 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.