Downloads · 30 days
0
Lematrixai/corn-model-disease-detection
corn-model-disease-detection is a machine learning model from Lematrixai. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
A deep learning model that can detect two common maize diseases from leaf images: - Maize Streak Virus (MSV) - Maize Lethal Necrosis (MLN)
Downloads · 30 days
0
Access
Public
Updated Jun 9, 2025
Repo size
2.5 MB
Likes
0
Public
Click a slice to open those files.
.h51.8 MB · 70%
From the Hugging Face model README
A deep learning model that can detect two common maize diseases from leaf images:
You can use this model in your applications via the Hugging Face Inference API:
import requests
API_URL = "https://api-inference.huggingface.co/models/YOUR_USERNAME/maize-disease-detection"
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}
def query(filename):
with open(filename, "rb") as f:
data = f.read()
response = requests.post(API_URL, headers=headers, data=data)
return response.json()
To use this model in a Next.js application:
// pages/api/predict.ts
import type { NextApiRequest, NextApiResponse } from 'next'
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
if (req.method !== 'POST') {
return res.status(405).json({ message: 'Method not allowed' })
}
try {
const response = await fetch(
'https://api-inference.huggingface.co/models/YOUR_USERNAME/maize-disease-detection',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HUGGINGFACE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(req.body),
}
)
const data = await response.json()
res.status(200).json(data)
} catch (error) {
res.status(500).json({ message: 'Error processing request' })
}
}
// components/DiseaseDetector.tsx
import { useState } from 'react'
export default function DiseaseDetector() {
const [file, setFile] = useState<File | null>(null)
const [prediction, setPrediction] = useState<any>(null)
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
if (!file) return
const formData = new FormData()
formData.append('file', file)
try {
const response = await fetch('/api/predict', {
method: 'POST',
body: formData,
})
const data = await response.json()
setPrediction(data)
} catch (error) {
console.error('Error:', error)
}
}
return (
<div>
<form onSubmit={handleSubmit}>
<input
type="file"
accept="image/*"
onChange={(e) => setFile(e.target.files?.[0] || null)}
/>
<button type="submit">Analyze</button>
</form>
{prediction && (
<div>
<h3>Results:</h3>
<pre>{JSON.stringify(prediction, null, 2)}</pre>
</div>
)}
</div>
)
}
MIT License