spawn99 commited on
Commit
91191df
·
verified ·
1 Parent(s): da9327b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -29
app.py CHANGED
@@ -8,8 +8,7 @@ License: MIT License
8
  import torch
9
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
10
  import gradio as gr
11
- import json # Added for JSON conversion
12
-
13
 
14
  def run_inference(review_text: str) -> str:
15
  """
@@ -90,31 +89,24 @@ def predict_wine_variety(country: str, description: str, output_format: str) ->
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()
 
8
  import torch
9
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
10
  import gradio as gr
11
+ import json
 
12
 
13
  def run_inference(review_text: str) -> str:
14
  """
 
89
 
90
 
91
  if __name__ == "__main__":
92
+ iface = gr.Interface(
93
+ fn=predict_wine_variety,
94
+ inputs=[
95
+ gr.Textbox(label="Country", placeholder="Enter country of origin..."),
96
+ gr.Textbox(label="Description", placeholder="Enter wine review description..."),
97
+ gr.Radio(choices=["JSON", "Text"], value="JSON", label="Output Format")
98
+ ],
99
+ outputs=gr.Textbox(label="Prediction"),
100
+ title="Wine Variety Predictor",
101
+ description=(
102
+ "Predict the wine variety based on the country and wine review.\n\n"
103
+ "This tool uses [ModernBERT](https://huggingface.co/answerdotai/ModernBERT-base), "
104
+ "an encoder-only classifier, trained on the [wine reviews dataset]"
105
+ "(https://huggingface.co/datasets/spawn99/wine-reviews)\n\n"
106
+ "**Model Resources:**\n"
107
+ "- Model: [spawn99/modernbert-wine-classification](https://huggingface.co/spawn99/modernbert-wine-classification)\n"
108
+ "- Dataset: [spawn99/wine-reviews](https://huggingface.co/datasets/spawn99/wine-reviews)\n\n"
109
+ "*Cavit Erginsoy, 2025*\n"
 
 
 
 
 
 
110
  )
111
+ )
112
+ iface.launch()