예제 #1
0
    def get_latent_batch(self, images):

        start = time.time()

        for i, image in enumerate(images):
            hax_fn = "/home/" + username(
            ) + "/dlrc17-gdk/ext/OnAVOS/custom_dataset/JPEGImages/480p/live_fol/00001_" + str(
                i + 1).zfill(4) + ".png"
            # hax_fn = "/home/" + username() + "/Documents/class_data_final/live_fol/00001_" + str(i).zfill(4) + ".png"
            scipy.misc.imsave(hax_fn, image)

        out_layer_name = self.config.unicode("output_embedding_layer",
                                             "outputTriplet")
        out_layer = self.test_network.tower_layers[0][out_layer_name]
        assert len(out_layer.outputs) == 1
        out_feature = out_layer.outputs[0]
        out_feature_size = out_layer.n_features

        path_name = "live_fol/"
        path = self.valid_data.test_case
        idx_placeholder = self.valid_data.idx_placeholder
        num_images = len(images)
        idx_value = [0, num_images, 0, 0]

        feature_val = self.session.run(out_feature,
                                       feed_dict={
                                           idx_placeholder: idx_value,
                                           path: path_name
                                       })

        end = time.time()
        elapsed = end - start
        # print(elapsed)
        return feature_val
예제 #2
0
 def __init__(self, config, subset, coord, fraction=1.0):
   data_dir = "/fastwork/" + username() + "/mywork/data/PascalVOC/benchmark_RELEASE/dataset/"
   super(PascalVOCInteractiveCorrectionFeed, self).__init__(config, subset, coord, data_dir, fraction,
                                                            NUM_CLASSES, VOID_LABEL, INPUT_SIZE,
                                                            use_old_label=True, use_clicks=True)
   self.fraction = fraction
   self.old_label_as_distance_transform = config.bool("old_label_as_distance_transform", True)
예제 #3
0
 def __init__(self, config, subset, coord, fraction=1.0):
   data_dir = "/fastwork/" + username() + "/mywork/data/PascalVOC/benchmark_RELEASE/dataset/"
   self.use_old_label = config.bool("use_old_label", False)
   super(PascalVOCInteractiveFeed, self).__init__(config, subset, coord, data_dir, fraction,
                                                  NUM_CLASSES, VOID_LABEL, INPUT_SIZE,
                                                  use_old_label=self.use_old_label, use_clicks=True)
   self.fraction = fraction
예제 #4
0
 def __init__(self, engine):
     super(ClusteringForwarder, self).__init__(engine)
     self.output_folder = "/home/" + username(
     ) + "/vision/clustering/data/new_forward/"
     self.RCNN = engine.config.bool("forward_rcnn", False)
     self.network = None
     self.data = None
     self.output_file_name = engine.config.str("output_file_name", "")
예제 #5
0
    def segment(self, image, size, save_flag=False, threshold=0.5):

        start = time.time()
        orig_size = (int(image.shape[1]), int(image.shape[0]))
        resized_image = scipy.misc.imresize(image, size)

        # hax_fn = "/home/"+username()+"/dlrc17-gdk/ext/OnAVOS/custom_dataset/JPEGImages/480p/live/000000.jpg"
        hax_fn = "/home/" + username(
        ) + "/Documents/Segment/OnAVOSold/custom_dataset/JPEGImages/480p/live/000000.jpg"
        scipy.misc.imsave(hax_fn, resized_image)

        tensor_out = self.test_network.y_softmax
        tensor_out_argmax = tf.argmax(tensor_out, 3)

        feed_dict = {}
        # feed_dict = {self.valid_data.img_placeholder: [image]}
        # feed_dict = {self.test_network.img: [image]}

        prob, y_argmax = self.session.run([tensor_out, tensor_out_argmax],
                                          feed_dict=feed_dict)
        prob = prob[0, :, :, 1]
        # print(prob.max(),prob.min(),prob.mean())
        orig_size_prob = scipy.misc.imresize(prob, orig_size, interp='bicubic')
        # print(orig_size_prob.max(), orig_size_prob.min(), orig_size_prob.mean())
        mask = ((orig_size_prob > 255 * threshold) * 255).astype("uint8")

        # mask = (y_argmax * 255).astype("uint8")
        # mask = numpy.squeeze(mask, axis=0)
        # prob = numpy.squeeze(prob[:, :, :, 1], axis=0)

        # mask = numpy.fliplr(mask)
        # prob = numpy.fliplr(prob)

        mask = scipy.misc.imresize(mask, size)
        prob = scipy.misc.imresize(prob, size)

        # if save_flag:
        #   saver_fol = "/home/dlrc/dlrc17-gdk/gdk/imagproc/video_output/"
        #   # fol_num = str(len(os.listdir(saver_fol))).zfill(4)
        #   # if not os.path.exists(fol_num):
        #   #     os.makedirs(fol_num)
        #   # dir = saver_fol+fol_num+"/"
        #   dir = saver_fol
        #   im_num = str(len(os.listdir(dir))).zfill(4)
        #   scipy.misc.imsave(dir+"/"+im_num+".jpg", image)
        #   scipy.misc.imsave(dir + "/" + im_num + ".png", mask)

        end = time.time()
        elapsed = end - start
        return mask, prob
예제 #6
0
import glob
import tensorflow as tf
from datasets.Dataset import ImageDataset
from datasets.Util.Util import username, unique_list
from datasets.Util.Reader import load_label_default
from datasets.Util.Normalization import normalize

NUM_CLASSES = 2
VOID_LABEL = 255  # for translation augmentation
DAVIS_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/DAVIS/"
# DAVIS2017_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/DAVIS2017/"
#DAVIS2017_DEFAULT_PATH = "/home/" + username() + "/dlrc17-gdk/ext/OnAVOS/custom_dataset/"
DAVIS2017_DEFAULT_PATH = "/home/" + username(
) + "/Documents/Segment/OnAVOSold/custom_dataset/"
DAVIS_FLOW_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS_data/"
DAVIS_LUCID_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS_data/lucid/"
DAVIS2017_LUCID_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS2017_data/lucid/"
DAVIS_IMAGE_SIZE = (480, 854)
DAVIS2017_IMAGE_SIZE = (480, None)


def read_image_and_annotation_list(fn, data_dir):
    imgs = []
    ans = []
    with open(fn) as f:
        for l in f:
            sp = l.split()
            an = data_dir + sp[1]
예제 #7
0
파일: main.py 프로젝트: dbadrian/gdk_dlrc17
#!/usr/bin/env python
import sys
import os
from datasets.Util.Util import username
# base_file=os.getcwd()
base_file = '/home/'+username()+'/dlrc17-gdk/ext/OnAVOS'
os.chdir(base_file)
sys.path.insert(0,'./')
sys.path.insert(0,'datasets')


from Engine import Engine
from Config import Config
from Log import log
import tensorflow as tf


def init_log(config):
  log_dir = config.dir("log_dir", "logs")
  model = config.unicode("model")
  filename = log_dir + model + ".log"
  verbosity = config.int("log_verbosity", 3)
  log.initialize([filename], [verbosity], [])


def main(_):
  assert len(sys.argv) == 2, "usage: main.py <config>"
  config_path = sys.argv[1]
  assert os.path.exists(config_path), config_path
  try:
    config = Config(config_path)
예제 #8
0
import glob
import tensorflow as tf
from datasets.Dataset import ImageDataset
from datasets.Util.Util import username, unique_list
from datasets.Util.Reader import load_label_default

NUM_CLASSES = 2
VOID_LABEL = 255  # for translation augmentation
DAVIS_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/DAVIS/"
DAVIS2017_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/DAVIS2017/"
DAVIS_FLOW_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS_data/"
DAVIS_LUCID_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS_data/lucid/"
DAVIS2017_LUCID_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/DAVIS2017_data/lucid/"
#DAVIS_IMAGE_SIZE = (480, None)#854)
DAVIS_IMAGE_SIZE = (None, None)  #854)
DAVIS2017_IMAGE_SIZE = (480, None)


def read_image_and_annotation_list(fn, data_dir):
    imgs = []
    ans = []
    with open(fn) as f:
        for l in f:
            sp = l.split()
            an = data_dir + sp[1]
            im = data_dir + sp[0]
            imgs.append(im)
            ans.append(an)
예제 #9
0
import tensorflow as tf
import numpy
import os

from datasets.Dataset import Dataset
from datasets.Util.Reader import load_image_tensorflow, load_normalized_image_tensorflow
from datasets.Util.Util import smart_shape, username
from datasets.Augmentors import parse_augmentors, apply_augmentors
from datasets.Util.Normalization import normalize

# CUHK03_DEFAULT_PATH = "/fastwork/" + username() + "/mywork/data/CUHK03/"
CUHK03_DEFAULT_PATH = "/home/" + username(
) + "/dlrc17-gdk/ext/OnAVOS/custom_dataset/JPEGImages/480p/"
DEFAULT_INPUT_SIZE = [270, 90]
CUHK03_VOID_LABEL = 255


class CUHK03Dataset(Dataset):
    def __init__(self, config, subset, coord):
        super(CUHK03Dataset, self).__init__(subset)
        assert subset in ("train", "valid"), subset
        self.ignore_classes = None
        self.config = config
        self.subset = subset
        self.coord = coord
        self.data_dir = config.unicode("data_dir", CUHK03_DEFAULT_PATH)
        self.model = config.unicode("model", "")
        self.train_folder = config.unicode("train_folder", "train/")
        self.epoch_length = config.int("epoch_length", 1000)
        self.n_classes = config.int("num_classes", None)
        self.input_size = config.int_list("input_size", DEFAULT_INPUT_SIZE)
예제 #10
0
from datasets.Dataset import ImageDataset
from datasets.Util.Util import username
from datasets.Util import Reader

VOID_LABEL = 255
PASCAL_VOC_DEFAULT_PATH = "/fastwork/" + username(
) + "/mywork/data/PascalVOC/benchmark_RELEASE/dataset/"
INPUT_SIZE = (None, None)


class PascalVOCDataset(ImageDataset):
    def __init__(self,
                 config,
                 subset,
                 coord,
                 label_postproc_fn,
                 name,
                 num_classes,
                 label_load_fn=Reader.load_label_default,
                 img_load_fn=Reader.load_img_default,
                 fraction=1.0,
                 ignore_classes=[]):
        super(PascalVOCDataset,
              self).__init__(name,
                             PASCAL_VOC_DEFAULT_PATH,
                             num_classes,
                             config,
                             subset,
                             coord,
                             INPUT_SIZE,
                             VOID_LABEL,