| import gradio as gr |
| from joblib import load |
|
|
| |
| model = load("logistic_model.joblib") |
| tfidf_vectorizer = load("tfidf_vectorizer.joblib") |
| mlb = load("label_binarizer.joblib") |
|
|
| |
| def classify_commit(message): |
| |
| X_tfidf = tfidf_vectorizer.transform([message]) |
|
|
| |
| prediction = model.predict(X_tfidf) |
| predicted_labels = mlb.inverse_transform(prediction) |
|
|
| |
| return ", ".join(predicted_labels[0]) if predicted_labels[0] else "No labels" |
|
|
| |
| demo = gr.Interface( |
| fn=classify_commit, |
| inputs=gr.Textbox( |
| label="Enter Commit Message", |
| placeholder="Type your commit message here...", |
| lines=3, |
| max_lines=5, |
| ), |
| outputs=gr.Textbox(label="Predicted Labels"), |
| title="π Commit Message Classifier", |
| description="π This tool classifies commit messages into categories like 'bug fix', 'feature addition', and more. Enter a message to see the predicted labels.", |
| examples=[ |
| ["Fixed a bug in the login feature"], |
| ["Added a new user dashboard"], |
| ["Updated order processing logic"], |
| ["Refactored the payment module for better performance"], |
| ], |
| theme="compact", |
| ) |
|
|
| |
| demo.launch(share=True, server_port=7860) |
|
|