def generate(dataset_fname, image_dir):
    data = dataset.Classifier("page-blocks.data", blank=True)
    for image_file in os.listdir(image_dir):
        if os.path.isdir(image_file):
            continue
        file_type = mimetypes.guess_type(image_file)[0]
        if file_type is not None and file_type.startswith("image/"):
            image = imagetools.load(os.path.join(image_dir, image_file))
            chosen_class_name = ui.classify_image(image)
            data.add(image, dataset.CLASS_NAMES.index(chosen_class_name))
    data.write_to(dataset_fname)
def generate(dataset_fname, image_dir):
	data = dataset.Classifier("page-blocks.data", blank=True)
	for image_file in os.listdir(image_dir):
		if os.path.isdir(image_file):
			continue
		file_type = mimetypes.guess_type(image_file)[0]
		if file_type is not None and file_type.startswith("image/"):
			image = imagetools.load(os.path.join(image_dir, image_file))
			chosen_class_name = ui.classify_image(image)
			data.add(image, dataset.CLASS_NAMES.index(chosen_class_name))
	data.write_to(dataset_fname)
def classify(dataset_fname, image_fname):
    c = dataset.Classifier(dataset_fname)
    c.build()
    print c.classify_one(imagetools.load(image_fname))
def classify(dataset_fname, image_fname):
	c = dataset.Classifier(dataset_fname)
	c.build()
	print c.classify_one(imagetools.load(image_fname))