Esempio n. 1
0
val_trainId_label_paths = cPickle.load(open(path.join(output_dir, "val_trainId_label_paths.pkl"), "rb"))
val_data = list(zip(val_img_paths, val_trainId_label_paths))

# validate_files(val_img_paths)
# validate_files(val_trainId_label_paths)
# exit()

# compute the number of batches needed to iterate through the val data:
no_of_val_imgs = len(val_img_paths)
no_of_val_batches = int(no_of_val_imgs / batch_size)

# define params needed for label to onehot label conversion:
layer_idx = np.arange(img_height).reshape(img_height, 1)
component_idx = np.tile(np.arange(img_width), (img_height, 1))

model = ENet_model(model_id, img_height=img_height, img_width=img_width, batch_size=batch_size)
no_of_classes = model.no_of_classes


def evaluate_on_val():
    random.shuffle(val_data)
    val_img_paths, val_trainId_label_paths = zip(*val_data)

    val_batch_losses = []
    batch_pointer = 0
    for step in range(no_of_val_batches):
        batch_imgs = np.zeros((batch_size, img_height, img_width, 3), dtype=np.float32)
        batch_onehot_labels = np.zeros((batch_size, img_height, img_width,
                                        no_of_classes), dtype=np.float32)

        for i in range(batch_size):
Esempio n. 2
0
    batch_size = 1
    img_height = 288
    img_width = 800
    colors = np.array([
        [0, 0, 0],
        [255, 0, 0],
        [0, 255, 0],
        [0, 0, 255],
        [255, 255, 0],
    ],
                      dtype=np.float32)
    no_of_classes = 5
    model = ENet_model(model_id,
                       img_height=img_height,
                       img_width=img_width,
                       batch_size=batch_size,
                       no_classes=no_of_classes)
    train_mean_channels = pickle.load(open("data/mean_channels.pkl", 'rb'))
    input_mean = train_mean_channels  #[103.939, 116.779, 123.68] # [0, 0, 0]
    input_std = [1, 1, 1]
    normalizer = transforms.GroupNormalize(mean=(input_mean, (0, )),
                                           std=(input_std, (1, )))

    # load the mean color channels of the train imgs:
    train_mean_channels = pickle.load(open("data/mean_channels.pkl", 'rb'))

    # create a saver for restoring variables/parameters:
    saver = tf.train.Saver(tf.trainable_variables(),
                           write_version=tf.train.SaverDef.V2)
Esempio n. 3
0
from utilities import label_img_to_color

from model import ENet_model

project_dir = "/home/ipcvg/tensorflow_enet/segmentation/"

data_dir = project_dir + "data/"

model_id = "sequence_run"

batch_size = 1
img_height = 512
img_width = 1024


model = ENet_model(model_id, img_height=img_height, img_width=img_width,
            batch_size=batch_size)

no_of_classes = model.no_of_classes

# load the mean color channels of the train imgs:
train_mean_channels = cPickle.load(open("data/mean_channels.pkl"))

# load the sequence data:
seq_frames_dir = "/home/ipcvg/tensorflow_enet/segmentation/data/srikar_test/"
seq_frame_paths = []
frame_names = sorted(os.listdir(seq_frames_dir))
for step, frame_name in enumerate(frame_names):
    if step % 100 == 0:
        print(step)

    frame_path = seq_frames_dir + frame_name
data_dir = project_dir + "data/"

model_id = "sequence_run"

label=[]
batch_size = 1
img_height =512
img_width = 1024
count=0
x=0
z=0
y=0
alpha=0.1
beta = (1.0 - alpha)

model = ENet_model(model_id, img_height=img_height, img_width=img_width, batch_size=batch_size)

no_of_classes = model.no_of_classes

results_dir = model.project_dir + "motion14/"
#results_dir1=model.project_dir+"motion15/"
path=results_dir 

# load the mean color channels of the train imgs:
train_mean_channels = cPickle.load(open("data/mean_channels.pkl"))
################################FEATURE EXTRACTION#########################################
def feature(frame):
        gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        edges=cv2.Canny(frame,100,200) 
        rho = 1  # distance resolution in pixels of the Hough grid
        theta = np.pi / 180  # angular resolution in radians of the Hough grid