impy icon indicating copy to clipboard operation
impy copied to clipboard

How to keep original file names

Open qqaadir opened this issue 5 years ago • 3 comments

Dear @lozuwa

This is a great work. I have created new reduced images and annotations successfully. I am wondering is there a way to keep original files name instead of assigning new names. I have the following code

def main():
    images_path = os.path.join(os.getcwd(), "images")
    annotations_path = os.path.join(os.getcwd(), "Annotation")
    # Define the name of the dataset
    dbName = "CarsDataset"
	# Create an object of ObjectDetectionDataset
    obda = ObjectDetectionDataset(imagesDirectory=images_path, annotationsDirectory=annotations_path, databaseName = dbName)
	# Reduce the dataset to smaller Rois of smaller ROIs of shape 1092 x 1080.
    offset=[480, 360]
    images_output_path = os.path.join(os.getcwd(), "images_reduced")
    annotations_output_path = os.path.join(os.getcwd(), "Annotation_reduced")
    obda.reduceDatasetByRois(offset = offset, outputImageDirectory = images_output_path, outputAnnotationDirectory = annotations_output_path)

if __name__ == "__main__":
	main()

this code append CarsDataset at the start of each image and it assigns some ids to each image. What I want is to keep original image names, for example if my file name is image_1 and your library create four crops, I want to name those crops as image_1_1, .... images_1_4. Thank you for your suggestions.

qqaadir avatar Jun 02 '20 02:06 qqaadir

This fork has the feature you need. https://github.com/baicaigithub/impy

baicaigithub avatar Aug 15 '20 19:08 baicaigithub

@baicaigithub Could please you give an example on how your fork retains filenames? I checked your link, the example provided is still the same as on the original page. Thank you.

qqaadir avatar Aug 16 '20 12:08 qqaadir

I only hacked a few places to keep the original names. Didn't update the doc.

baicaigithub avatar Aug 17 '20 04:08 baicaigithub