Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import torch
|
2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
import gradio as gr
|
@@ -83,22 +90,31 @@ def predict_wine_variety(country: str, description: str, output_format: str) ->
|
|
83 |
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
"
|
99 |
-
"This tool uses ModernBERT, an encoder-only classifier, trained on the wine reviews dataset\n"
|
100 |
-
"(model: spawn99/modernbert-wine-classification, dataset: spawn99/wine-reviews).\n\n"
|
101 |
-
"Use the Output Format selector to toggle between a JSON-formatted result and a plain text prediction."
|
102 |
)
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Wine Variety Predictor
|
3 |
+
Author: Cavit Erginsoy
|
4 |
+
Year: 2025
|
5 |
+
License: MIT License
|
6 |
+
"""
|
7 |
+
|
8 |
import torch
|
9 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
10 |
import gradio as gr
|
|
|
90 |
|
91 |
|
92 |
if __name__ == "__main__":
|
93 |
+
# Using Gradio Blocks to allow custom layout with a footer.
|
94 |
+
with gr.Blocks() as demo:
|
95 |
+
gr.Markdown(
|
96 |
+
"""
|
97 |
+
# Wine Variety Predictor
|
98 |
+
|
99 |
+
Predict the wine variety based on the country and wine review.
|
100 |
+
|
101 |
+
This tool uses ModernBERT, an encoder-only classifier, trained on the wine reviews dataset
|
102 |
+
(model: spawn99/modernbert-wine-classification, dataset: spawn99/wine-reviews).
|
103 |
+
|
104 |
+
Use the Output Format selector to toggle between a JSON-formatted result and a plain text prediction.
|
105 |
+
"""
|
|
|
|
|
|
|
106 |
)
|
107 |
+
with gr.Row():
|
108 |
+
country_input = gr.Textbox(label="Country", placeholder="Enter country of origin...")
|
109 |
+
description_input = gr.Textbox(label="Description", placeholder="Enter wine review description...")
|
110 |
+
output_format_input = gr.Radio(choices=["JSON", "Text"], value="JSON", label="Output Format")
|
111 |
+
prediction_output = gr.Textbox(label="Prediction")
|
112 |
+
submit_btn = gr.Button("Predict")
|
113 |
+
submit_btn.click(
|
114 |
+
fn=predict_wine_variety,
|
115 |
+
inputs=[country_input, description_input, output_format_input],
|
116 |
+
outputs=prediction_output
|
117 |
+
)
|
118 |
+
# Footer added at the bottom of the page
|
119 |
+
gr.Markdown("---\n**Cavit Erginsoy, 2025, MIT License**")
|
120 |
+
demo.launch()
|