mgbam commited on
Commit
c54beea
·
verified ·
1 Parent(s): 82856e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -1,24 +1,25 @@
1
- from transformers import pipeline
2
-
3
- # Load the model
4
- pipe = pipeline("text-classification", model="mgbam/roberta-yelp-genomic-bottleneck")
5
-
6
- # Gradio app
7
- import gradio as gr
8
-
9
- def classify_text(text):
10
- results = pipe(text)
11
- return results
12
-
13
- # Create Gradio interface
14
- interface = gr.Interface(
15
- fn=classify_text,
16
- inputs="text",
17
- outputs="json",
18
- title="Text Classification",
19
- description="Classify text using the RoBERTa-Yelp-Genomic-Bottleneck model."
20
- )
21
-
22
- if __name__ == "__main__":
23
- interface.launch()
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()