import gradio as gr import joblib from textclassification import IndependentMultiLabelClassifier # Load the saved classifier model classifier = joblib.load('classifier_model.joblib') # Define the prediction function def predict_text(text): predictions = classifier.predict_proba([text]) result = {category: prob for category, prob in predictions} return result # Create the Gradio interface interface = gr.Interface( fn=predict_text, inputs=gr.Textbox(label="Enter your text"), outputs=gr.Label(label="Prediction Scores"), title="Multi-label Text Classifier", description="Enter a text to see the prediction scores for each category." ) # Launch the app if __name__ == "__main__": interface.launch(share=True, debug=True)