Skip to main content

Library for Deep Residual Multiscale Segmenter

Project description

Library for Deep Residual Multiscale Segmenter (resmcseg)

Build Status Build status

The python library of Deep Residual Multiscale Segmenter (autonet). Current version just supports the KERAS package of deep learning and will extend to the others in the future.

Major modules

model

  • gResMCSeg: major class to obtain a deep extensive residual multiscale
    FCN. You can setup its aruments. See the class and its member functions' help for details.
  • gResMCSegPre: major class to make semantic segmentation for binary and multi class.
  • pretrainedmodel: function to download the pretrained models using the DSTL and ZURICH datasets from the Google cloud

util

  • segmetrics: main metrics including jaccard index, MIoU, and loss functions etc.
  • helper: helper functions including color mapping etc.

data

  • data: function to access one image for Zurich to test the model's prediction.

Installation

You can directly install it using the following command for the latest version:

sudo pip install resmcseg

Note for installation and use

Compiler requirements

resmcseg requires a C++11 compliant compiler to be available.

Runtime requirements

resmcseg requires installation of Keras with support of Tensorflow as the backend system of deep learning (to support Keras). Also Pandas and Numpy should be installed. Specifics: Keras>=2.2.2; opencv2>=3.4.1,tensorflow,numpy,sklearn, pandas, gdal,tifffile etc.

Use case

The homepage of the github for the package, resmcseg provides specific examples for use of the library:
https://github.com/lspatial/resmcsegpub

License

The resmcseg is provided under a MIT license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

Test call

import os
import cv2
from keras.models import load_model,model_from_json
from resmcseg.util.segmetrics import compute_iou,jaccard,mean_iouC,miou,mean_iou
from resmcseg.model.gresmcseg_pre import gResMCSegPre
from resmcseg.model.resizelayer import ResizeLayer
from resmcseg.model.pretrainedmodel import downloadPretrainedModel
from resmcseg.util.helper import bce_dice_loss,jaccard_coef,jaccard_coef_int,jaccard_coef1
from resmcseg.util.helper import onehot_to_rgb,color_dict
from resmcseg.data import dload

modelFl='/tmp/model_strwei.h5'
if not os.path.isfile(modelFl):
    downloadPretrainedModel('ZURICH',destination=modelFl)
model = load_model(modelFl,custom_objects={'ResizeLayer': ResizeLayer,'bce_dice_loss':bce_dice_loss,
        'mean_iou':mean_iou,'jaccard_coef':jaccard_coef, 'jaccard_coef1':jaccard_coef1,'miou':miou,
        'jaccard_coef_int':jaccard_coef_int,'mean_iouC': mean_iouC})
ppre=gResMCSegPre(patchsize=224,bordersize=16,overprop=0.3)
img, mask = dload()
imgres = ppre.preAImgMulti(img, model, 9)
mskImg = onehot_to_rgb(imgres, color_dict)
fpath = "/tmp/zurich1img_pre.jpg"
cv2.imwrite(fpath, cv2.cvtColor(mskImg, cv2.COLOR_RGB2BGR), [int(cv2.IMWRITE_JPEG_QUALITY), 100])
y_pred = imgres.flatten()
y_true = mask.flatten()
iou = compute_iou(imgres, mask)
jacard = jaccard(imgres, mask)
print("iou : " + str(iou) + '; jacard is ', jacard)

Collaboration

Welcome to contact Dr. Lianfa Li (Email: lspatial@gmail.com or lilf@lreis.ac.cn).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resmcseg-0.1.65.tar.gz (6.6 MB view details)

Uploaded Source

File details

Details for the file resmcseg-0.1.65.tar.gz.

File metadata

  • Download URL: resmcseg-0.1.65.tar.gz
  • Upload date:
  • Size: 6.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.10

File hashes

Hashes for resmcseg-0.1.65.tar.gz
Algorithm Hash digest
SHA256 34c94bcaa7d41ad92c834ec7706aaa5f39a4ddece7ed72a71f8c04b9a4a307b4
MD5 73a11927fd15f6b3db4daef2fcc9f8c6
BLAKE2b-256 524d8a747a0b97a133b8693772950ab421d5536728d8e5df4190027dd659e4c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page