Skip to content

DeepLab semantic segmentation#1

Open
RvanderLaan wants to merge 4 commits into
masterfrom
segmentation/deeplab
Open

DeepLab semantic segmentation#1
RvanderLaan wants to merge 4 commits into
masterfrom
segmentation/deeplab

Conversation

@RvanderLaan

Copy link
Copy Markdown
Collaborator

CopiedAdded the DeepLab semantic segmentation model from the notebook of https://github.com/tensorflow/models/tree/master/research/deeplab
The default model is downloaded if it does not exist the first time. Segmentation takes about 3 seconds on my GPU, 6 on my CPU
A demo can be run from the segmenter.py file

…/tensorflow/models/tree/master/research/deeplab

The default model is downloaded if it does not exist the first time. Segmentation takes about 3 seconds on my GPU, 6 on my CPU
A demo can be run from the `segmenter.py` file

@raviautar raviautar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine, needs some improvements. When running the code, make sure the latest version of tensorflow-gpu (v1.7.0) is installed

Comment thread segmentation/segmenter.py Outdated
# Enable this to run on CPU instead of GPU (if GPU is used by default)
# os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

def load_model(MODEL_NAME='mobilenetv2_coco_voctrainaug'):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an example script, it seems more appropriate to move this function to the DeeplabModel.py file. This way, we do not have to copy and function every time we create a new model.

Comment thread segmentation/segmenter.py Outdated
'xception_coco_voctrainval': 'deeplabv3_pascal_trainval_2018_01_04.tar.gz',
}

urllib.request.urlretrieve(_DOWNLOAD_URL_PREFIX + _MODEL_URLS[MODEL_NAME], _TARBALL_PATH)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a folder named models to this directory, since this throws an error if it does not exist.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, though you can't commit an empty folder. But I'll add a call to create the folder if it doesn't exist

Comment thread segmentation/segmenter.py Outdated
t0 = time.clock()

print('running model...')
resized_im, seg_map = MODEL.run(orignal_im)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resized_im and seg_map do not appear to have the same dimensions as the original image, which will pose problems for us later when finding bounding boxes and cropping out. Could you please make sure this is the case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do! In the DeeplabModel they are resized to a certain maximum resolution before running the segmentation

@RvanderLaan RvanderLaan added the wip label May 5, 2018
…solution and fixed an issue of the models directory not existing before downloading
@raviautar

raviautar commented May 7, 2018

Copy link
Copy Markdown
Owner

The inconsistent shapes seems to be fixed. The load_pretrained_model, however, still is not included in the DeepLab module. Could you include this?

In addition, 2 minor fixes:

  • Rename segmenter.py to segmentor.py
  • Reformat DeepLabModel.py with 4 spaces as indent (Ctrl + Alt + L in IntelliJ)

@RvanderLaan

Copy link
Copy Markdown
Collaborator Author

Indentation is fixed, but I don't think segmentor is the right word

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants