| 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 a commit message here...", |
| lines=3 |
| ), |
| outputs=gr.Label(label="Predicted Categories"), |
| title="π Commit Message Classifier", |
| description="π Enter a commit message to classify it into predefined categories.\n\nπ‘ **Example:** \"Fixed a bug in login feature\" β Predicted Categories: `bug fix`", |
| theme="default", |
| examples=[ |
| "Fixed a bug in login feature", |
| "Added a new user dashboard", |
| "Updated order processing logic", |
| "Refactored payment module for better efficiency" |
| ], |
| live=True, |
| allow_flagging="never" |
| ) |
|
|
| |
| css = """ |
| body { |
| font-family: 'Arial', sans-serif; |
| background-color: #f7f9fc; |
| margin: 0; |
| padding: 0; |
| } |
| #component-0 { |
| background-color: #ffffff; |
| border: 1px solid #ddd; |
| border-radius: 10px; |
| padding: 20px; |
| box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); |
| } |
| textarea { |
| font-size: 16px; |
| border-radius: 5px; |
| border: 1px solid #ccc; |
| padding: 10px; |
| resize: none; |
| } |
| label { |
| font-weight: bold; |
| font-size: 18px; |
| } |
| """ |
|
|
| |
| demo.launch(share=True, server_port=7860, auth=("user", "password"), css=css) |
|
|