• 大小: 2.06MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: Python
  • 标签:

资源简介

Weakly Supervised Segmentation with Tensorflow. Implements instance segmentation as described in Simple Does It: Weakly Supervised Instance and Semantic Segmentation, by Khoreva et al. (CVPR 2017).

资源截图

代码片段和文件信息

“““
bboxes.py

Bounding box utility functions.

Written by Phil Ferriere

Licensed under the MIT License (see LICENSE for details)

based on:
    - https://github.com/matterport/Mask_RCNN/blob/master/utils.py
        Copyright (c) 2017 Matterport Inc. / Written by Waleed Abdulla
        Licensed under the MIT License

References for future work:
    - https://github.com/tensorflow/models/blob/master/research/object_detection/utils/np_box_ops.py
      https://github.com/tensorflow/models/blob/master/research/object_detection/utils/ops.py
        Copyright 2017 The TensorFlow Authors. All Rights Reserved.
        Licensed under the Apache License Version 2.0
    - https://github.com/tangyuhao/DAVIS-2016-Chanllege-Solution/blob/master/Step1-SSD/tf_extended/bboxes.py
        https://github.com/tangyuhao/DAVIS-2016-Chanllege-Solution/blob/master/Step1-SSD/bounding_box.py
        Copyright (c) 2017 Paul Balanca / Written by Paul Balanca
        Licensed under the Apache License Version 2.0 January 2004
“““

import numpy as np

def extract_bbox(mask order=‘y1x1y2x2‘):
    “““Compute bounding box from a mask.
    Param:
        mask: [height width]. Mask pixels are either >0 or 0.
        order: [‘y1x1y2x2‘ | ]
    Returns:
        bbox numpy array [y1 x1 y2 x2] or tuple x1 y1 x2 y2.
    based on:
        https://stackoverflow.com/questions/31400769/bounding-box-of-numpy-array
    “““
    horizontal_indicies = np.where(np.any(mask axis=0))[0]
    vertical_indicies = np.where(np.any(mask axis=1))[0]
    if horizontal_indicies.shape[0]:
        x1 x2 = horizontal_indicies[[0 -1]]
        y1 y2 = vertical_indicies[[0 -1]]
        # x2 and y2 should not be part of the box. Increment by 1.
        x2 += 1
        y2 += 1
    else:
        # No mask for this instance. Might happen due to
        # resizing or cropping. Set bbox to zeros
        x1 x2 y1 y2 = 0 0 0 0
    if order == ‘x1y1x2y2‘:
        return x1 y1 x2 y2
    else:
        return np.array([y1 x1 y2 x2])

def extract_bboxes(mask):
    “““Compute bounding boxes from an array of masks.
    Params
        mask: [height width num_instances]. Mask pixels are either >0 or 0.
    Returns:
        bbox numpy arrays [num_instances (y1 x1 y2 x2)].
    “““
    boxes = np.zeros([mask.shape[-1] 4] dtype=np.int32)
    for i in range(mask.shape[-1]):
        boxes[i] = extract_bbox(mask[: : i])
    return boxes.astype(np.int32)


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-15 08:29  tfwss-master\
     文件        1219  2018-07-15 08:29  tfwss-master\.gitignore
     文件        1070  2018-07-15 08:29  tfwss-master\LICENSE
     文件        8455  2018-07-15 08:29  tfwss-master\README.md
     目录           0  2018-07-15 08:29  tfwss-master\tfwss\
     文件        2447  2018-07-15 08:29  tfwss-master\tfwss\bboxes.py
     文件       21748  2018-07-15 08:29  tfwss-master\tfwss\dataset.py
     目录           0  2018-07-15 08:29  tfwss-master\tfwss\img\
     文件       39737  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000203.jpg
     文件       37489  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000219.jpg
     文件       28139  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000553.jpg
     文件       20152  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000581.jpg
     文件       52708  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000657.jpg
     文件       27581  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000727.jpg
     文件       25443  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000795.jpg
     文件       34823  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000811.jpg
     文件       32854  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000825.jpg
     文件       42743  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000839.jpg
     文件       27821  2018-07-15 08:29  tfwss-master\tfwss\img\2008_000957.jpg
     文件       24394  2018-07-15 08:29  tfwss-master\tfwss\img\2008_001113.jpg
     文件       33931  2018-07-15 08:29  tfwss-master\tfwss\img\2008_001199.jpg
     文件       50882  2018-07-15 08:29  tfwss-master\tfwss\img\2008_001867.jpg
     文件       43266  2018-07-15 08:29  tfwss-master\tfwss\img\2008_002191.jpg
     文件       26811  2018-07-15 08:29  tfwss-master\tfwss\img\2008_002673.jpg
     文件       38417  2018-07-15 08:29  tfwss-master\tfwss\img\2008_003055.jpg
     文件       46450  2018-07-15 08:29  tfwss-master\tfwss\img\2008_003141.jpg
     文件       16254  2018-07-15 08:29  tfwss-master\tfwss\img\data_files.png
     文件       63958  2018-07-15 08:29  tfwss-master\tfwss\img\vgg16.png
     文件      140495  2018-07-15 08:29  tfwss-master\tfwss\img\vgg_16_4chan_weak_dsn2_loss.png
     文件      139545  2018-07-15 08:29  tfwss-master\tfwss\img\vgg_16_4chan_weak_dsn3_loss.png
     文件      134404  2018-07-15 08:29  tfwss-master\tfwss\img\vgg_16_4chan_weak_dsn4_loss.png
............此处省略25个文件信息

评论

共有 条评论