|
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" |
|
|
|
|
|
custom_css = """ |
|
body { |
|
background-color: #d0f0fd; /* Light Blue */ |
|
} |
|
""" |
|
|
|
|
|
demo = gr.Interface( |
|
fn=classify_commit, |
|
inputs=gr.Textbox( |
|
label="Enter Commit Message", |
|
placeholder="Type your Dockerfile-related commit message here...", |
|
lines=3, |
|
max_lines=5, |
|
), |
|
outputs=gr.Textbox(label="Predicted Labels"), |
|
title="π³ Dockerfile Commit Message Classifier", |
|
description="π Classify commit messages related to Dockerfiles into categories like 'bug fix', 'feature addition', and more. Enter a commit message to get the predictions.", |
|
examples=[ |
|
["Fixed an issue with the base image version in Dockerfile"], |
|
["Added a new multistage build to optimize Docker image size"], |
|
["Updated the Python version in Dockerfile to 3.10"], |
|
["Sort Dockerfile"], |
|
["Added COPY instruction for configuration files"], |
|
], |
|
article=""" |
|
**How to Use**: |
|
- Enter a commit message related to Dockerfiles. |
|
- The tool predicts categories such as 'bug fix', 'code refactoring', 'feature addition', or 'maintenance/other'. |
|
|
|
**Examples**: |
|
- Fixing base image versions. |
|
- Adding new Docker build stages. |
|
- Updating dependencies in Dockerfiles. |
|
""", |
|
css=custom_css, |
|
) |
|
|
|
|
|
demo.launch(share=True, server_port=7860) |
|
|