Back to Foundry
R&D Lab · Prototype

Plant Disease Classifier

Plant DiseaseClassifier

A small web service that puts a trained plant-disease model behind a drag-and-drop page. Upload a photo of a leaf and the server returns the predicted disease class, a confidence score, the full probability spread and how long inference took.

R&D Lab · Model serving · Built by Pinelogix

The Idea

A lot of useful machine-learning work ends as a model file on a disk, with nothing anyone can actually use. This experiment was about the last mile: taking a trained image classifier and putting a clean, honest interface around it, quickly and with as few moving parts as possible.

The starting point was a trained Keras model in HDF5 format, with no label map or preprocessing notes alongside it. So part of the job was working out what the model actually expects, and then making sure the interface reports exactly what the model says, without guessing at class names.

What We Built

  • ✦
    Model inspection A small inspection script prints the model's input and output shapes and its configuration. The saved architecture is an EfficientNetB0 backbone feeding a 256-unit dense layer and a 15-way softmax, with 224×224 RGB input.
  • ✦
    Load once, serve many The model is loaded and warmed up once when the server starts, not on every request. The server reads the expected input size from the model itself and falls back to 224×224 only if the shape can't be read.
  • ✦
    A defensive predict endpoint A single upload endpoint rejects anything that isn't an image and converts PNGs with transparency, or other modes, to RGB. It resizes to the model's input, runs inference, and returns clear errors if the model failed to load.
  • ✦
    Transparent results Each response carries the top class index, its confidence, every class probability and the inference time in milliseconds, so the output can be checked rather than taken on trust.
  • ✦
    A focused upload UI The page accepts a dragged or browsed image with a preview and a remove button, and has loading, result and error states. Results show a confidence bar, the inference time and a toggle for the raw probability vector.

The Stack

A FastAPI app served by Uvicorn, with TensorFlow / Keras for inference, Pillow and NumPy for image handling, and python-multipart for uploads. The front end is plain HTML, CSS and JavaScript, mounted as static files on the same app, so the service is one process with no separate front-end build. The dependency list runs to six packages.

What We Learned

The serving layer was the easy part. Not knowing how the model was trained was the real constraint. Without a label map, the service reports predictions as numbered disease classes rather than inventing names. Without preprocessing notes, images are passed as raw 0–255 values, on the reasoning that EfficientNet in Keras normalises its own inputs. The code marks the 1/255 rescale as the switch to flip if predictions look wrong. The service covers the full path from upload to result. Turning it into a field tool would need the original class list and a validated preprocessing step.

Need something similar? Reach out. We turn trained models into small, dependable services people can actually use.