Downloads · 30 days
23
7% of all-time downloads
Ruzindana/cropsense-mobilenetv2
cropsense-mobilenetv2 is a image classification model from Ruzindana. Use it when you need a label for an image. It is set up for keras. The card lists the license as mit.
This is a MobileNetV2-based deep learning model trained to detect crop diseases in leaf images. The model is specifically designed for smallholder farmers in Rwanda to identify common crop diseases.
Downloads · 30 days
23
7% of all-time downloads
All-time downloads
331
Public
Repo size
25.6 MB
Likes
0
Public
Click a slice to open those files.
.keras25.6 MB · 100%
From the Hugging Face model README
This is a MobileNetV2-based deep learning model trained to detect crop diseases in leaf images. The model is specifically designed for smallholder farmers in Rwanda to identify common crop diseases.
Model Type: Image Classification
Framework: Keras/TensorFlow
Architecture: MobileNetV2
Input: 224x224 RGB images
Output: Disease classification (Healthy, Powdery, Rust)
from huggingface_hub import hf_hub_download
import tensorflow as tf
from PIL import Image
import numpy as np
# Download model from Hugging Face
model_path = hf_hub_download(
repo_id="Ruzindana/cropsense-mobilenetv2",
filename="best_MobileNetV2.keras"
)
# Load the model
model = tf.keras.models.load_model(model_path)
# Load class names
import json
with open(hf_hub_download(
repo_id="Ruzindana/cropsense-mobilenetv2",
filename="model_metadata.json"
)) as f:
metadata = json.load(f)
class_names = metadata.get("classes", ["Healthy", "Powdery", "Rust"])
# Preprocess image
def preprocess_image(image_path):
img = Image.open(image_path).resize((224, 224))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
return img_array
# Make prediction
image = preprocess_image("path/to/leaf_image.jpg")
predictions = model.predict(image)
predicted_class_idx = np.argmax(predictions[0])
confidence = float(predictions[0][predicted_class_idx])
predicted_class = class_names[predicted_class_idx]
print(f"Prediction: {predicted_class} ({confidence*100:.2f}% confidence)")
Set the environment variable:
export HUGGINGFACE_MODEL_ID="Ruzindana/cropsense-mobilenetv2"
The backend will automatically download and use the model.
The model was trained on a dataset of crop leaf images from Rwanda, focusing on:
If you use this model, please cite:
@model{cropsense-mobilenetv2,
author = {Ruzindana, Diana},
title = {CropSense MobileNetV2 - Crop Disease Detection Model},
year = {2025},
url = {https://huggingface.co/Ruzindana/cropsense-mobilenetv2}
}
MIT License - See LICENSE file for details
For questions or support, please contact the model maintainer.