Coder Social home page Coder Social logo

u2net-tensorflow's Introduction

u2net-tensorflow

A tensorflow implementation of the U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection using Keras & Functional API

Based on the PyTorch version by NathanUA, PDillis, vincentzhang, and chenyangh

Network structure

Notebook

If you just want to play with the model, I've setup a Google Colab Notebook that lets you train the model on DUTS-TR, and it's fun to watch the model learn to mask an image of the Space Needle that it's never seen before while it trains. Training takes ~60 minutes to get to noticeable results, but you should train for several hours to use it for testing. Please let me know if you have any questions.

Network learning space needle

Setup

virtualenv venv
source venv/bin/activate
pip install tensorflow matplotlib opencv-python wget

Training

OPTIONAL: Download the DUTS-TR dataset and unzip into the data directory to load the training set:

wget http://saliencydetection.net/duts/download/DUTS-TR.zip
unzip DUTS-TR.zip -d data

If train.py does not detect the dataset is present when run, it will automatically try to download and setup the dataset before initiating training. If you have a custom dataset, you can update dataset_dir, image_dir, and mask_dir in config.py. Images will be rescaled

To begin training, simply run:

python train.py

Weights are automatically saved every save_interval iterations to weights/u2net.h5. These can be overwritten by passing the appropriate arguments. See python train.py -h for args.

Evaluation

Use eval.py to evaluate the model on images:

python eval.py --weights=weights/u2net.h5 --image=examples/skateboard.jpg

By default, the output images are saved in the out subdirectory

Custom Usage

The U2NET class can be used to instatiate a modular instance of the U2-Net network

from model.u2net import U2NET

u2net = U2NET()
out = u2net(inp)

u2net-tensorflow's People

Contributors

patrickisroman 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.