Spaces:
Runtime error
Runtime error
| 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() | |