Spaces:
Sleeping
Sleeping
File size: 561 Bytes
b6aa8ff | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import json
from tensorflow.keras.preprocessing.image import ImageDataGenerator
IMG_SIZE = (224,224)
datagen = ImageDataGenerator(rescale=1./255, validation_split=0.2)
# Use same folder you trained with
generator = datagen.flow_from_directory(
"d:/SIH/images",
target_size=IMG_SIZE,
batch_size=32,
class_mode="categorical",
subset="training"
)
# Save class indices
with open("class_indices.json", "w") as f:
json.dump(generator.class_indices, f)
print("✅ Class indices saved as class_indices.json")
print(generator.class_indices)
|