Update app.py
Browse files
app.py
CHANGED
|
@@ -18,44 +18,77 @@ def classify_commit(message):
|
|
| 18 |
# Return the predicted labels as a comma-separated string
|
| 19 |
return ", ".join(predicted_labels[0]) if predicted_labels[0] else "No labels"
|
| 20 |
|
| 21 |
-
# Custom CSS for
|
| 22 |
custom_css = """
|
| 23 |
body {
|
| 24 |
-
background-color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
"""
|
| 27 |
|
| 28 |
-
# Create
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
""
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
# Launch the Gradio app
|
| 61 |
demo.launch(share=True, server_port=7860)
|
|
|
|
| 18 |
# Return the predicted labels as a comma-separated string
|
| 19 |
return ", ".join(predicted_labels[0]) if predicted_labels[0] else "No labels"
|
| 20 |
|
| 21 |
+
# Custom CSS for Improved Aesthetics
|
| 22 |
custom_css = """
|
| 23 |
body {
|
| 24 |
+
background-color: #e6f7ff; /* Light Blue Background */
|
| 25 |
+
font-family: 'Arial', sans-serif;
|
| 26 |
+
}
|
| 27 |
+
.gradio-container {
|
| 28 |
+
padding: 20px;
|
| 29 |
+
border-radius: 10px;
|
| 30 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
|
| 31 |
+
max-width: 800px;
|
| 32 |
+
margin: auto;
|
| 33 |
+
}
|
| 34 |
+
h1, h2 {
|
| 35 |
+
color: #004d80; /* Darker Blue for headings */
|
| 36 |
+
text-align: center;
|
| 37 |
+
}
|
| 38 |
+
footer {
|
| 39 |
+
text-align: center;
|
| 40 |
+
color: #555;
|
| 41 |
+
font-size: 12px;
|
| 42 |
}
|
| 43 |
"""
|
| 44 |
|
| 45 |
+
# Create the layout with Gradio Blocks
|
| 46 |
+
with gr.Blocks(css=custom_css) as demo:
|
| 47 |
+
gr.Markdown("<h1>🐳 Dockerfile Commit Message Classifier</h1>")
|
| 48 |
+
gr.Markdown(
|
| 49 |
+
"""
|
| 50 |
+
<p>🔍 Use this tool to classify Dockerfile-related commit messages into categories like <b>'bug fix'</b>,
|
| 51 |
+
<b>'feature addition'</b>, and more. Enter a commit message below to see the prediction.</p>
|
| 52 |
+
"""
|
| 53 |
+
)
|
| 54 |
+
with gr.Row():
|
| 55 |
+
with gr.Column(scale=1):
|
| 56 |
+
commit_message_input = gr.Textbox(
|
| 57 |
+
label="Enter Commit Message",
|
| 58 |
+
placeholder="Type your Dockerfile-related commit message here...",
|
| 59 |
+
lines=3,
|
| 60 |
+
max_lines=5,
|
| 61 |
+
)
|
| 62 |
+
with gr.Column(scale=1):
|
| 63 |
+
predicted_output = gr.Textbox(
|
| 64 |
+
label="Predicted Labels",
|
| 65 |
+
interactive=False,
|
| 66 |
+
lines=2,
|
| 67 |
+
)
|
| 68 |
+
classify_button = gr.Button("Classify", elem_id="classify-btn")
|
| 69 |
+
classify_button.click(
|
| 70 |
+
classify_commit, inputs=commit_message_input, outputs=predicted_output
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
gr.Markdown("<h2>📝 Examples</h2>")
|
| 74 |
+
gr.Examples(
|
| 75 |
+
examples=[
|
| 76 |
+
["Fixed an issue with the base image version in Dockerfile"],
|
| 77 |
+
["Added a new multistage build to optimize Docker image size"],
|
| 78 |
+
["Updated the Python version in Dockerfile to 3.10"],
|
| 79 |
+
["Sort Dockerfile"],
|
| 80 |
+
["Added COPY instruction for configuration files"],
|
| 81 |
+
],
|
| 82 |
+
inputs=commit_message_input,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
gr.Markdown(
|
| 86 |
+
"""
|
| 87 |
+
<footer>
|
| 88 |
+
<p>⚙️ Built with ❤️ using <b>Gradio</b>. Try it now!</p>
|
| 89 |
+
</footer>
|
| 90 |
+
"""
|
| 91 |
+
)
|
| 92 |
|
| 93 |
# Launch the Gradio app
|
| 94 |
demo.launch(share=True, server_port=7860)
|