コード例 #1
0
#! /usr/bin/env python
from TensorflowToolbox.utility import file_io
import sys

if __name__ == "__main__":
    if len(sys.argv) < 2:
        exit(1)
    file_name = sys.argv[1]
    file_list = file_io.read_file(file_name)
    file_list.sort()
    file_io.save_file(file_list, file_name)
コード例 #2
0
def save_file(file_list, file_name):
    file_io.save_file(file_list, file_list_dir + file_name, True)
コード例 #3
0
    data_list = [trancos_data_path + t for t in data_list]

    data_list = file_list_to_list(data_list, unroll_num)

    desmap_list = [d.replace(data_ext, desmap_ext) for d in \
                        data_list]
    
    mask_list = [d.replace(data_ext, mask_ext) for d in \
                        data_list]

    file_list = [i + " " + d + " "  + m for i, d, m in \
                zip(data_list, desmap_list, mask_list)]

    return file_list 

if __name__ == "__main__":
    data_ext = ".jpg"
    desmap_ext = ".desmap"
    mask_ext = "_mask.npy"
    unroll_num = 5

    file_list_dir = "../file_list/"
    save_train_file_name = "trancos_train_list1.txt"
    save_test_file_name = "trancos_test_list1.txt"

    train_file = file_list_to_train_list("../file_list/trancos_org_trainval.txt")
    test_file = file_list_to_train_list("../file_list/trancos_org_test.txt")

    file_io.save_file(train_file, file_list_dir + save_train_file_name, True)
    file_io.save_file(test_file, file_list_dir + save_test_file_name, True)
コード例 #4
0
import numpy as np
import cv2
from TensorflowToolbox.utility import file_io

desmap_dir = "/media/dog/data/UCSD/gtDensities/"

desmap_list = file_io.get_listfile(desmap_dir, "desmap")
new_list = list()
for f in desmap_list:
    num = np.sum(np.fromfile(f, np.float32))
    format_num = "%.2f" % num
    new_list.append(f + " " + format_num)

new_list.sort()
file_io.save_file(new_list, "ucsd_file_label_num.txt")
コード例 #5
0

if __name__ == "__main__":
    unroll_num = 5

    for i in range(2):
        if i == 0:
            file_list_name = "/home/shanghang/video_analysis/file_list/world_expo_train_list1.txt"
            save_file_name = "../file_list/world_expo_train_list1.txt"
        else:
            file_list_name = "/home/shanghang/video_analysis/file_list/world_expo_test_list1.txt"
            save_file_name = "../file_list/world_expo_test_list1.txt"

        file_list = file_io.read_file(file_list_name)
        file_list.sort()
        unrolled_list = list()

        for i, f in enumerate(file_list):
            if i == 0:
                start_video = f.split("/")[0][:6]
                start_i = i
            else:
                video = f.split("/")[0][:6]
                if start_video != video or i == len(file_list) - 1:
                    new_list = file_list_to_list(file_list[start_i:i], unroll_num)
                    unrolled_list += new_list
        unrolled_list = [reorder_str(f) for f in unrolled_list]
        file_io.save_file(unrolled_list, save_file_name, True)


コード例 #6
0
            data_list += curr_data_list
            desmap_list += curr_desmap_list
            mask_list += curr_mask_list

        #partition = 0.7
        #train_data_len = int(len(data_list) * partition)

        #random.shuffle(data_list)
        #train_data = data_list[:train_data_len]
        #test_data = data_list[train_data_len:]

        #train_list += [d + " " + d.replace(data_ext, label_ext) for d in train_data]
        #test_list += [d + " " + d.replace(data_ext, label_ext) for d in test_data]

    full_file_list = [i + " "+ d + " " + m for i, d, m in \
                zip(data_list, desmap_list, mask_list)]

    file_num = len(full_file_list)
    train_file_list_name = 'train_list1.txt'
    train_len = int(file_num * 0.7)

    train_file_list = full_file_list[:train_len]
    file_io.save_file(train_file_list, file_list_dir + train_file_list_name,
                      True)

    test_file_list_name = 'test_list1.txt'
    test_file_list = full_file_list[train_len:]
    file_io.save_file(test_file_list, file_list_dir + test_file_list_name,
                      True)
コード例 #7
0
            file_list = train_list
        else:
            file_list = test_list

        img_list = file_io.get_listfile(img_dir, ".jpg")
        scale_str = str(new_dsize[0])

        for img_name in img_list:
            if not img_name.endswith("_" + scale_str + ".jpg"):
                continue
            label_name = img_name.replace(img_dir,
                                          desmap_dir).replace(".jpg", ".npy")
            mask_name = mask_dir + img_name.split("/")[-1][:6] \
                        + "_mask_" + scale_str + ".npy"

            if not os.path.exists(label_name):
                print(label_name, "is not exist")
                exit(1)

            if not os.path.exists(mask_name):
                print(mask_name, "is not exist")
                exit(1)

            file_list.append(" ".join([img_name, label_name, mask_name]))

    train_file_name = "../file_list/world_expo_train_list1.txt"
    test_file_name = "../file_list/world_expo_test_list1.txt"
    file_io.save_file(train_list, train_file_name, True)

    file_io.save_file(test_list, test_file_name, True)