File size: 574 Bytes
069e071 403b617 069e071 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from keras.models import load_model
import numpy as np
labels = ['Chalky Soil', 'Mary Soil', 'Sand', 'Slit SOil', 'Alluvial Soil', 'Black Soil', 'Clay Soil', 'Red Soil']
MODEL_PATH = r"DenseNet121v2_95.h5"
def load_CNN_model():
model = load_model(MODEL_PATH)
print("model loaded")
return model
def classify_image(img):
model = load_CNN_model()
prediction = model.predict(img)
predicted_class = np.argmax(prediction)
predicted_label = labels[predicted_class]
accuracy = prediction[0][predicted_class]
return predicted_label, accuracy
|