Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load the model
|
5 |
+
pipe = pipeline("text-classification", model="mgbam/roberta-yelp-genomic-bottleneck")
|
6 |
+
|
7 |
+
def classify_text(text):
|
8 |
+
results = pipe(text)
|
9 |
+
# Extract and format results
|
10 |
+
formatted_results = [
|
11 |
+
f"Label: {result['label']}, Score: {result['score']:.2f}" for result in results
|
12 |
+
]
|
13 |
+
return "\n".join(formatted_results)
|
14 |
+
|
15 |
+
# Gradio interface
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=classify_text,
|
18 |
+
inputs="text",
|
19 |
+
outputs="text",
|
20 |
+
title="Text Classification",
|
21 |
+
description="Classify text using the RoBERTa-Yelp-Genomic-Bottleneck model."
|
22 |
+
)
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
interface.launch()
|