An image classification model that detects diseases in rice crops from a leaf photograph. It identifies 11 output classes covering common rice diseases (such as Blast, Brown spot, Bacterial leaf blight, Sheath blight, Tungro and False Smut) as well as healthy plants, and returns the predicted condition with a confidence score.
This model is a multi-class image classifier for rice (Oryza sativa) leaf disease detection, built with TensorFlow/Keras and stored in Keras HDF5 format (01_rice_disease_11_class.hdf5). It is loaded once at server startup using keras.models.load_model() to avoid per-request loading overhead, and it assigns each input image to one of 11 output classes covering common rice diseases and healthy plants. The model accepts a single RGB leaf image per request. The image is sent as a base64-encoded string inside a JSON body, decoded and saved to disk, then read with OpenCV, converted from BGR to RGB, and resized to 256 × 256 pixels using INTER_AREA interpolation. A batch dimension is added, giving an input tensor of shape (1, 256, 256, 3) with uint8 values in the range 0-255. The inference pipeline applies no explicit normalization, because the /255 scaling step is disabled, so any rescaling must be handled inside the model itself. The model outputs a probability vector of shape (1, 11), which is flattened to (11,). The prediction rule is top-1 argmax, and the corresponding label is looked up from an ordered class list that must match the model’s training output order exactly. The server verifies that the output length equals the number of labels and raises an error otherwise. The class order is: Bacterial leaf blight, Brown spot, False Smut, Blast, Blast, Sheath blight, Sheath blight, Narrow brown leaf spot, Tungro, Sheath rot, and Healthy. Two disease names each appear twice, so the 11 outputs map to 9 distinct condition labels. The model is served through a Flask REST API at POST /model/disease_detection_rice with Content-Type: application/json. The request body contains the image under the key image_file. A successful response (HTTP 200) returns message (the predicted label), c_name (the crop name, “Rice”), probability1 (the top-1 probability from 0 to 1, rounded to four decimals) and result (true). Missing or invalid JSON, a missing image, or invalid base64 encoding returns HTTP 400 with result: false, while preprocessing failures, inference errors or an output/label count mismatch return HTTP 500. A health-check endpoint, GET /model/first, confirms the API is running. The service depends on Flask, TensorFlow/Keras, OpenCV, NumPy and pybase64, and processes one image synchronously per request. The model has several limitations. It produces a single top-1 label per image, with no multi-label support and no “unknown” or out-of-distribution class, so unrelated problems such as nutrient deficiency or pest damage may be assigned to the nearest known disease. The probabilities may not be well calibrated, so low-confidence outputs should be treated with caution. Accuracy may drop with blurry or poorly lit images, cluttered backgrounds, or disease stages, varieties and regions not represented in the training data. The model is intended as decision support and not as a replacement for expert diagnosis. Details on architecture or backbone, parameter count, output activation, training dataset and size, data split, augmentation, loss function, optimizer, hyperparameters, accuracy, per-class precision/recall/F1 and inference latency are not available in the code and should be added from your training records. Also confirm whether the model contains a built-in rescaling layer, since the pipeline passes raw 0-255 pixel values. If you share the output of model.summary(), I can complete these details accurately.
ICAR Data Use License
ICAR / IASRI
Image Classification Model
Scikit-Learn
Restricted
AgriKosh
12/10/26 11:25:13
250.82 MB
To preview this file, you need to be a registered user. Please complete the registration process to gain access and continue viewing the content.
ICAR Data Use License
© 2026 - Copyright AIKosh. All rights reserved.