• 大小: 1.03MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-28
  • 语言: 其他
  • 标签: FCN  

资源简介

tensorflow实现FCN_源代码,可以在自己的电脑上跑程序

资源截图

代码片段和文件信息

“““
Code ideas from https://github.com/Newmu/dcgan and tensorflow mnist dataset reader
“““
import numpy as np
import scipy.misc as misc


class BatchDatset:
    files = []
    images = []
    annotations = []
    image_options = {}
    batch_offset = 0
    epochs_completed = 0

    def __init__(self records_list image_options={}):
        “““
        Intialize a generic file reader with batching for list of files
        :param records_list: list of file records to read -
        sample record: {‘image‘: f ‘annotation‘: annotation_file ‘filename‘: filename}
        :param image_options: A dictionary of options for modifying the output image
        Available options:
        resize = True/ False
        resize_size = #size of output image - does bilinear resize
        color=True/False
        “““
        print(“Initializing Batch Dataset Reader...“)
        print(image_options)
        self.files = records_list
        self.image_options = image_options
        self._read_images()

    def _read_images(self):
        self.__channels = True
        self.images = np.array([self._transform(filename[‘image‘]) for filename in self.files])
        self.__channels = False
        self.annotations = np.array(
            [np.expand_dims(self._transform(filename[‘annotation‘]) axis=3) for filename in self.files])
        print (self.images.shape)
        print (self.annotations.shape)

    def _transform(self filename):
        image = misc.imread(filename)
        if self.__channels and len(image.shape) < 3:  # make sure images are of shape(hw3)
            image = np.array([image for i in range(3)])

        if self.image_options.get(“resize“ False) and self.image_options[“resize“]:
            resize_size = int(self.image_options[“resize_size“])
            resize_image = misc.imresize(image
                                         [resize_size resize_size] interp=‘nearest‘)
        else:
            resize_image = image

        return np.array(resize_image)

    def get_records(self):
        return self.images self.annotations

    def reset_batch_offset(self offset=0):
        self.batch_offset = offset

    def next_batch(self batch_size):
        start = self.batch_offset
        self.batch_offset += batch_size
        if self.batch_offset > self.images.shape[0]:
            # Finished epoch
            self.epochs_completed += 1
            print(“****************** Epochs completed: “ + str(self.epochs_completed) + “******************“)
            # Shuffle the data
            perm = np.arange(self.images.shape[0])
            np.random.shuffle(perm)
            self.images = self.images[perm]
            self.annotations = self.annotations[perm]
            # Start next epoch
            start = 0
            self.batch_offset = batch_size

        end = self.batch_offset
        return self.images[start:end] self.annotations[start:end]

    def get_random_batch(self batch_size):
        indexes = np.random.randint(0 self.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-04-05 16:29  FCN.tensorflow-master\
     文件          42  2017-04-05 16:29  FCN.tensorflow-master\.gitignore
     文件        3108  2017-04-05 16:29  FCN.tensorflow-master\BatchDatsetReader.py
     文件        9796  2017-04-05 16:29  FCN.tensorflow-master\FCN.py
     文件        1074  2017-04-05 16:29  FCN.tensorflow-master\LICENSE
     文件        4617  2017-04-05 16:29  FCN.tensorflow-master\README.md
     文件        8480  2017-04-05 16:29  FCN.tensorflow-master\TensorflowUtils.py
     文件           0  2017-04-05 16:29  FCN.tensorflow-master\__init__.py
     目录           0  2017-04-05 16:29  FCN.tensorflow-master\logs\
     目录           0  2017-04-05 16:29  FCN.tensorflow-master\logs\images\
     文件      113332  2017-04-05 16:29  FCN.tensorflow-master\logs\images\Image_Cmaped.ipynb
     文件       20876  2017-04-05 16:29  FCN.tensorflow-master\logs\images\conv_1_1_gradient.png
     文件       16359  2017-04-05 16:29  FCN.tensorflow-master\logs\images\conv_4_1_gradient.png
     文件       16447  2017-04-05 16:29  FCN.tensorflow-master\logs\images\conv_4_2_gradient.png
     文件       16355  2017-04-05 16:29  FCN.tensorflow-master\logs\images\conv_4_3_gradient.png
     文件        1928  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_0.png
     文件        2214  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_1.png
     文件        3875  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_2.png
     文件        3628  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_3.png
     文件        3490  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_4.png
     文件        1439  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_5.png
     文件        3062  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_6.png
     文件        4309  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_7.png
     文件        3027  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_8.png
     文件        9716  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c0.png
     文件       10398  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c1.png
     文件       15633  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c2.png
     文件       13852  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c3.png
     文件       14244  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c4.png
     文件        8791  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c5.png
     文件       12713  2017-04-05 16:29  FCN.tensorflow-master\logs\images\gt_c6.png
............此处省略27个文件信息

评论

共有 条评论