I have an image dataset which I need to convert to Tensorflow format for image classification. The dataset JSON metadata format is shown below:
{
"0": {
"image_filepath": "images/0.jpg",
"anomaly_class": "A"
},
"1": {
"image_filepath": "images/1.jpg",
"anomaly_class": "B"
},
"2": {
"image_filepath": "images/2.jpg",
"anomaly_class": "C"
},
"3": {
"image_filepath": "images/3.jpg",
"anomaly_class": "D"
},
"4": {
"image_filepath": "images/4.jpg",
"anomaly_class": "E"
},
"5": {
"image_filepath": "images/5.jpg",
"anomaly_class": "F"
},
"6": {
"image_filepath": "images/6.jpg",
"anomaly_class": "G"
},
"7": {
"image_filepath": "images/7.jpg",
"anomaly_class": "H"
},
"8": {
"image_filepath": "images/8.jpg",
"anomaly_class": "I"
},
"9": {
"image_filepath": "images/9.jpg",
"anomaly_class": "J"
},
"10": {
"image_filepath": "images/10.jpg",
"anomaly_class": "K"
},
"11": {
"image_filepath": "images/11.jpg",
"anomaly_class": "L"
},
"12": {
"image_filepath": "images/12.jpg",
"anomaly_class": "M"
},
.
.
.
"1000": {
"image_filepath": "images/1000.jpg",
"anomaly_class": "A"
}
}
I want to write a Python script that creates folder names using value of the key "anomaly_class" and sorts/moves the images into their respective folders.
Any help please?