Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,22 +37,64 @@ def predict_sentiment(text):
|
|
| 37 |
|
| 38 |
|
| 39 |
css_str = """
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
font-
|
| 43 |
-
text-align: center;
|
| 44 |
-
margin-top: 20px;
|
| 45 |
}
|
| 46 |
|
| 47 |
-
.
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
"""
|
| 53 |
|
| 54 |
with gr.Blocks(css=css_str) as demo:
|
| 55 |
-
gr.
|
|
|
|
| 56 |
gr.Markdown(
|
| 57 |
"<div class='description'>Enter a sentence and see the predicted sentiment.</div>"
|
| 58 |
)
|
|
@@ -62,6 +104,7 @@ with gr.Blocks(css=css_str) as demo:
|
|
| 62 |
predict_btn = gr.Button("Predict Sentiment")
|
| 63 |
output_box = gr.Textbox(label="Predicted Sentiment")
|
| 64 |
predict_btn.click(fn=predict_sentiment, inputs=text_input, outputs=output_box)
|
|
|
|
| 65 |
|
| 66 |
if __name__ == "__main__":
|
| 67 |
demo.launch(share=True)
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
css_str = """
|
| 40 |
+
body {
|
| 41 |
+
background-color: #f0f2f5;
|
| 42 |
+
font-family: Arial, sans-serif;
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
+
.container {
|
| 46 |
+
max-width: 600px;
|
| 47 |
+
margin: 40px auto;
|
| 48 |
+
padding: 20px;
|
| 49 |
+
background: #ffffff;
|
| 50 |
+
border-radius: 8px;
|
| 51 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
h1 {
|
| 55 |
+
font-size: 36px;
|
| 56 |
+
font-weight: bold;
|
| 57 |
+
text-align: center;
|
| 58 |
+
margin-bottom: 10px;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.description {
|
| 62 |
+
font-size: 18px;
|
| 63 |
+
text-align: center;
|
| 64 |
+
margin-bottom: 30px;
|
| 65 |
+
color: #555555;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.gr-textbox textarea {
|
| 69 |
+
width: 100% !important;
|
| 70 |
+
padding: 10px;
|
| 71 |
+
font-size: 16px;
|
| 72 |
+
border-radius: 5px;
|
| 73 |
+
border: 1px solid #ccc;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.gr-button {
|
| 77 |
+
background-color: #007BFF;
|
| 78 |
+
color: #ffffff;
|
| 79 |
+
padding: 12px 24px;
|
| 80 |
+
font-size: 16px;
|
| 81 |
+
border: none;
|
| 82 |
+
border-radius: 5px;
|
| 83 |
+
cursor: pointer;
|
| 84 |
+
width: 100%;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.gr-button:hover {
|
| 88 |
+
background-color: #0056b3;
|
| 89 |
+
}
|
| 90 |
+
.gr-textbox textarea[readonly] {
|
| 91 |
+
background-color: #f9f9f9;
|
| 92 |
}
|
| 93 |
"""
|
| 94 |
|
| 95 |
with gr.Blocks(css=css_str) as demo:
|
| 96 |
+
gr.HTML("<div class='container'>")
|
| 97 |
+
gr.Markdown("<h1>Sentiment Analysis</h1>")
|
| 98 |
gr.Markdown(
|
| 99 |
"<div class='description'>Enter a sentence and see the predicted sentiment.</div>"
|
| 100 |
)
|
|
|
|
| 104 |
predict_btn = gr.Button("Predict Sentiment")
|
| 105 |
output_box = gr.Textbox(label="Predicted Sentiment")
|
| 106 |
predict_btn.click(fn=predict_sentiment, inputs=text_input, outputs=output_box)
|
| 107 |
+
gr.HTML("</div>")
|
| 108 |
|
| 109 |
if __name__ == "__main__":
|
| 110 |
demo.launch(share=True)
|