Coder Social home page Coder Social logo

deepgrabcut-pytorch's Introduction

Deep GrabCut (DeepGC)

DEXTR

This is a PyTorch implementation of Deep GrabCut, for object segmentation. We use DeepLab-v2 instead of DeconvNet in this repository.

Installation

The code was tested with Python 3.5. To use this code, please do:

  1. Clone the repo:

    git clone https://github.com/jfzhang95/DeepGrabCut-PyTorch
    cd DeepGrabCut-PyTorch
  2. Install dependencies:

    pip install -r requirements.txt
  3. Download pretained automatically. Or manually from GoogleDrive, and then put the model into models.

    gdown --output ./models/deepgc_pascal_epoch-99.pth --id 1N8bICHnFit6lLGvGwVu6bnDttyTk6wGH
  4. To try the demo of Deep GrabCut, please run:

    python demo.py
    # 1-When window appears, press "s"
    # 2-Draw circle
    # 3-Press spacebar and wait for 2 - 3 seconds

If installed correctly, the result should look like this:

Note that the provided model was trained only on VOC 2012 dataset. You will get better results if you train model on both VOC and SBD dataset.

To train Deep GrabCut on VOC (or VOC + SBD), please follow these additional steps:

  1. Download the pre-trained PSPNet model for semantic segmentation, taken from this repository.

    cd models/
    chmod +x download_pretrained_psp_model.sh
    ./download_pretrained_psp_model.sh
    cd ..
  2. Set the paths in mypath.py, so that they point to the location of VOC/SBD dataset.

  3. Run python train.py to train Deep Grabcut.

  4. If you want to train model on COCO dataset, you should first config COCO dataset path in mypath.py, and then run python train_coco.py to train model.

deepgrabcut-pytorch's People

Contributors

jfzhang95 avatar pablodz avatar sdxass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deepgrabcut-pytorch's Issues

TypeError

while I trying to run the train.py, the followed error occured:
Traceback (most recent call last):
File "/home/wq/Code/DeepGrabCut/train.py", line 147, in
loss = class_balanced_cross_entropy_loss(output, gts, size_average=True, batch_average=True)
File "/home/wq/Code/DeepGrabCut/layers/loss.py", line 45, in class_balanced_cross_entropy_loss
final_loss /= np.prod(label.size())
TypeError: div_() received an invalid combination of arguments - got (numpy.int64), but expected one of:

  • (Tensor other)
    didn't match because some of the arguments have invalid types: (!numpy.int64!)
  • (float other)
    didn't match because some of the arguments have invalid types: (!numpy.int64!)

could you give me some advice to solve this problem?

RUNTIME eRROR:

I have installed all the dependencies and followed the instruction.But still the pretrained model is not working

script missing

Dear developers, the folder "models" and its contents (such as the script "download_pretrained_psp_model.sh") are all completely missing. Would you please upload them? Thank you very much!

[Demo] Wrong set of seedpoint for cv2.floodFill

Hi there,

Thanks for this implementation!
I ran into a small problem running the demo: the cv2.floodFill was throwing errors saying the seedpoint had wrong values. Investigating a bit, I wonder if this section below
https://github.com/jfzhang95/DeepGrabCut-PyTorch/blob/master/demo.py#L97-L100
should not be commented.

Since left, right, up, down are used to put the seedpoint, if you leave this section uncommented (and that your monitor has more than twice the amount of pixels than the displayed image), opencv throws the mentioned error:

cv2.error: OpenCV(3.4.5) /io/opencv/modules/imgproc/src/floodfill.cpp:509: error: (-211:One of arguments' values is out of range) Seed point is outside of image in function 'floodFill'

Commenting the section fixes the error as the seedpoint changes from coordinates of 1000+ pixels down back to image dimensions:
dgc_fix

I'm unsure about how others managed to run the demo without commenting it though.

several questions

Hi,thanks for you provide this project,and several questions make me confused:
1.while training,what is the GT images?The bounding-box annotation images?Or the mask annotation images?Or no GT images?
2.The input images is the bounding-box annotation images,right?where can I get the dataset?
3.In the paper,it said that this method can accomplish semantic/instance segmentation,but this project only can realized object foreground segmentation.Is there any idea you could provide me to realize semantic segmentation?

Sincerely look forward to your reply.

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.