from huggingface_hub import hf_hub_download import pickle import gradio as gr import numpy as np # Download the model from Hugging Face Hub model_path = hf_hub_download(repo_id="suryadev1/knn", filename="knn_model_pc.pkl") # Load the model with open(model_path, 'rb') as f: knn = pickle.load(f) # Define the prediction function def predict(input_data): # Convert input_data to numpy array input_data = np.array(input_data).reshape(1, -1) # Make predictions predictions = knn.predict([[0.2,0.03,0.0,1.0,0.0]]) return predictions[0] iface = gr.Interface( fn=predict, inputs='text', outputs='text', title="KNN Model Prediction", description="Enter values for each feature to get a prediction." ) # Launch the interface iface.launch()