my-api-name1 / app.py
Abdul234's picture
Update app.py
f52bac6 verified
raw
history blame contribute delete
531 Bytes
import os
os.system('pip install joblib')
import gradio as gr
import joblib # Use this for scikit-learn models (change for PyTorch or TensorFlow)
# Load the trained model
model = joblib.load("model.pkl") # Change filename if needed
# Define a function to make predictions
def predict(input_data):
prediction = model.predict([input_data])
return str(prediction[0]) # Convert output to string
# Create Gradio API
interface = gr.Interface(fn=predict, inputs="text", outputs="text")
# Launch the API
interface.launch()