Skip to main content

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

Metadata

Release files for resmcseg 0.1.65

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resmcseg 0.1.65
File Size Uploaded
resmcseg-0.1.65.tar.gz 6.6 MB Details

Release files / resmcseg-0.1.65.tar.gz

Download URL resmcseg-0.1.65.tar.gz
Size 6.6 MB
Tags Source
SHA-256 checksum
How to use checksums
34c94bcaa7d41ad92c834ec7706aaa5f39a4ddece7ed72a71f8c04b9a4a307b4
BLAKE2b-256 checksum
How to use checksums
524d8a747a0b97a133b8693772950ab421d5536728d8e5df4190027dd659e4c0
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.65 This release

1 release file

0.1.64

1 release file

0.1.63

1 release file

0.1.62

1 release file

0.1.61

1 release file

0.1.6

1 release file

0.1.3

1 release file

0.1.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page