コード例 #1
0
def get_training_and_test_from_file(f_test, f_train):
    test = []
    training = []
    for line in f_test:
        if (line != ""):
            string_list = line.split()
            classification = string_list.pop()

            np = numpy.array(string_list)
            npfloat = np.astype(numpy.float)

            image_data_obj = ImageData(classification, npfloat)

            test.append(image_data_obj)
        else:
            print("Found one blank line")

    for line in f_train:
        if (line != ""):
            string_list = line.split()
            classification = string_list.pop()

            np = numpy.array(string_list)
            npfloat = np.astype(numpy.float)

            image_data_obj = ImageData(classification, npfloat)

            training.append(image_data_obj)
        else:
            print("Found one blank line")

    return training, test
コード例 #2
0
 def __init__(self, imgPath, initImage, initValid):
     #We should do error checking in main, but let's do it again
     if (FileClass.check_dir(imgPath) == False):
         print('ERROR: Directory \"%s\" does not exist' % IMAGE_PATH)
         sys.exit(1)
     #Getting all of the images in a manageable way
     AllImages = [
         ImageData.ImageData(os.path.join(root, name))
         for root, dirs, files in os.walk(IMAGE_PATH) for name in files
     ]
     self.ImgPath = AllImages
     self.Images = [ImageData.ImageData(initImage)]
     self.Validation = [ImageData.ImageData(initValid)]
コード例 #3
0
def folder_processing(classification, folder_path, file):
    data_list = []
    for filepath in glob(folder_path + '\\**'):
        image = imread(filepath)
        resized_image = resize(image, (80, 80), anti_aliasing=True)
        histograms_data = hog(resized_image,
                              orientations=8,
                              pixels_per_cell=(8, 8),
                              cells_per_block=(10, 10),
                              feature_vector=True)
        data = ImageData(classification, histograms_data)
        file.write(data.__repr__() + "\n")
        data_list.append(data)

    return data_list
コード例 #4
0
def get_data_from_file(file):
    image_data_list = []
    separated_characters = []
    character_data = []
    count = 0
    for line in file:
        if (line != ""):
            string_list = line.split()
            classification = string_list.pop()

            np = numpy.array(string_list)
            npfloat = np.astype(numpy.float)

            image_data_obj = ImageData(classification, npfloat)

            character_data.append(image_data_obj)

            image_data_list.append(image_data_obj)
        else:
            print("Found one blank line")

        count += 1
        if (count > 54):
            count = 0
            separated_characters.append(character_data)
            character_data = []

    return image_data_list, separated_characters
コード例 #5
0
    print("Seed was:", seed)

    #Will later have user input to find where the images are

    #Checking the directories
    if (FileClass.check_dir(IMAGE_PATH) == False):
        print('ERROR: Directory \"%s\" does not exist' % IMAGE_PATH)
        sys.exit(1)

    if (FileClass.check_dir(VALIDATION_PATH) == False):
        print("ERROR: Directory \"%s\" does not exist" % VALIDATION_PATH)
        sys.exit(1)

    #Making an ImageData object for all of the regular images
    AllImages = [
        ImageData.ImageData(os.path.join(root, name))
        for root, dirs, files in os.walk(IMAGE_PATH) for name in files
    ]

    #Making an ImageData object for all of the labeled images
    ValImages = [
        ImageData.ImageData(os.path.join(root, name))
        for root, dirs, files in os.walk(VALIDATION_PATH) for name in files
    ]

    #Let's get all possible values in lists
    Algos = ['FF', 'MCV', 'AC', 'FB', 'CV', 'WS', 'QS']  #Need to add floods
    #Taking out grayscale: CV, MCV, FD
    #Took out  'MCV', 'AC', FB, SC, CV, WS
    #Quickshift(QS) takes a long time, so I'm taking it out for now.
    betas = [i for i in range(0, 1000)]
コード例 #6
0
	rng = random.Random(seed)
	print("Seed was:", seed)
	#seed = SEED

	#Will later have user input to find where the images are
	#Checking the directories
	if (FileClass.check_dir(IMAGE_PATH) == False):
		print ('ERROR: Directory \"%s\" does not exist'%IMAGE_PATH)
		sys.exit(1)

	if(FileClass.check_dir(VALIDATION_PATH) == False):
		print("ERROR: Directory \"%s\" does not exist"%VALIDATION_PATH)
		sys.exit(1)

	#Making an ImageData object for all of the regular images
	AllImages = [ImageData.ImageData(os.path.join(root, name)) for 
		root, dirs, files in os.walk(IMAGE_PATH) for name in files]


	#Making an ImageData object for all of the labeled images
	ValImages = [ImageData.ImageData(os.path.join(root, name)) for
		root, dirs, files in os.walk(VALIDATION_PATH) for name in
		files]

	#Let's get all possible values in lists
	Algos = ['FB','SC','WS','CV','MCV','AC'] #Need to add floods
	#Quickshift(QS) takes a long time, so I'm taking it out for now.
	betas = [i for i in range(0,10000)]
	tolerance = [float(i)/1000 for i in range(0,1000,1)]
	scale = [i for i in range(0,10000)]
	sigma = [float(i)/100 for i in range(0,10,1)]
コード例 #7
0
	rng = random.Random(seed)
	print("Seed was:", seed)

	#Will later have user input to find where the images are

	#Checking the directories
	if (FileClass.check_dir(IMAGE_PATH) == False):
		print ('ERROR: Directory \"%s\" does not exist'%IMAGE_PATH)
		sys.exit(1)

	if(FileClass.check_dir(VALIDATION_PATH) == False):
		print("ERROR: Directory \"%s\" does not exist"%VALIDATION_PATH)
		sys.exit(1)

	#Making an ImageData object for all of the regular images
	AllImages = [ImageData.ImageData(os.path.join(root, name)) for 
		root, dirs, files in os.walk(IMAGE_PATH) for name in files]

	#Making an ImageData object for all of the labeled images
	ValImages = [ImageData.ImageData(os.path.join(root, name)) for
		root, dirs, files in os.walk(VALIDATION_PATH) for name in
		files]

	#Let's get all possible values in lists
	Algos = ['FF', 'MCV', 'AC', 'FB', 'CV', 'WS', 'QS'] #Need to add floods
	#Taking out grayscale: CV, MCV, FD
	#Took out  'MCV', 'AC', FB, SC, CV, WS
	#Quickshift(QS) takes a long time, so I'm taking it out for now.
	betas = [i for i in range(0,1000)]
	tolerance = [float(i)/1000 for i in range(0,1000,1)]
	scale = [i for i in range(0,1000)]