File size: 1,417 Bytes
e4cf7c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import numpy as np
from sklearn.preprocessing import LabelEncoder
from xgboost import XGBClassifier
import pickle

model = pickle.load('crop_recommendation_model.pkl')
le = pickle.load('label_encoder.pkl')

def recommend_crop(nitrogen, phosphorus, potassium, temperature, humidity, ph, rainfall)
    X_sample = nitrogen, phosphorus, potassium, temperature, humidity, ph, rainfall
        
    # Predict crop recommendations
    y_pred_sample = model.predict(X_sample)
        
    # Decode the predictions and ground truth back to crop names
    crops_pred = le.inverse_transform(y_pred_sample)

    return crops_pred

# Create the Gradio interface
interface = gr.Interface(
    fn=classify_potato_plant,
    inputs=[gr.Number(label="Nitrogen - Ratio of Nitrogen in the soil"), gr.Number(label="Phosphorus - Ratio of Phosphorus in the soil"), gr.Number(label="Potassium - Ratio of Potassium in the soil"), gr.Number(label="Temperature - In degrees Celsius"), gr.Number(label="Humidity - Relative humidity in %"), gr.Number(label="pH Value - pH value of the soil"), gr.Number(label="Rainfall - Rainfall in mm")],
    outputs=[gr.Textbox(label="Predicted Output"), gr.Textbox(label="Confidence Score")],
    title="Acres - PPDC",
    description="Acres PPDC, is our Potato Plant Disease Classification vision model, capable of accurately classifying potato plant disease, based on a single image."
)