spawn99 commited on
Commit
da9327b
·
verified ·
1 Parent(s): 9ea2a9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -18
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
- iface = gr.Interface(
87
- fn=predict_wine_variety,
88
- inputs=[
89
- gr.Textbox(label="Country", placeholder="Enter country of origin..."),
90
- gr.Textbox(label="Description", placeholder="Enter wine review description..."),
91
- # New radio input to choose between JSON and plain text output formats:
92
- gr.Radio(choices=["JSON", "Text"], value="JSON", label="Output Format")
93
- ],
94
- # Changed outputs to a Textbox so that plain text output shows naturally
95
- outputs=gr.Textbox(label="Prediction"),
96
- title="Wine Variety Predictor",
97
- description=(
98
- "Predict the wine variety based on the country and wine review.\n\n"
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
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
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()