|
from huggingface_hub import hf_hub_download |
|
import pickle |
|
import gradio as gr |
|
import numpy as np |
|
|
|
|
|
model_path = hf_hub_download(repo_id="suryadev1/knn", filename="knn_model_pc.pkl") |
|
|
|
|
|
with open(model_path, 'rb') as f: |
|
knn = pickle.load(f) |
|
|
|
|
|
def predict(input_data): |
|
|
|
input=input_data.split(' ') |
|
first=float(input[0]) |
|
second=float(input[1]) |
|
third=float(input[2]) |
|
fourth=float(input[3]) |
|
fifth=float(input[4]) |
|
|
|
predictions = knn.predict([[first,second,third,fourth,fifth]]) |
|
return predictions[0] |
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict, |
|
inputs='text', |
|
outputs='text', |
|
title="KNN Model Prediction", |
|
description="Enter values for each feature with spaces to get a prediction." |
|
) |
|
|
|
|
|
iface.launch() |
|
|