Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
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 |
-
|
94 |
-
|
95 |
-
|
96 |
-
"""
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
(
|
103 |
-
|
104 |
-
|
105 |
-
""
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
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 |
-
|
119 |
-
|
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()
|
|