sergiopaniego HF Staff commited on
Commit
4f1aff0
·
verified ·
1 Parent(s): 4c95735

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -0
app.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("text-classification", model="sergiopaniego/modernbert-banking77")
5
+
6
+ def get_text_classification(text_input):
7
+ prediction = classifier(text_input)
8
+ for i in range(len(prediction['labels'])):
9
+ output[prediction['labels'][i]] = prediction['scores'][i]
10
+ return output
11
+
12
+ examples = [["When did you send me my new card?"]]
13
+
14
+ css = """
15
+ footer {display:none !important}
16
+ .output-markdown{display:none !important}
17
+ .gr-button-primary {
18
+ z-index: 14;
19
+ height: 43px;
20
+ width: 130px;
21
+ left: 0px;
22
+ top: 0px;
23
+ padding: 0px;
24
+ cursor: pointer !important;
25
+ background: none rgb(17, 20, 45) !important;
26
+ border: none !important;
27
+ text-align: center !important;
28
+ font-family: Poppins !important;
29
+ font-size: 14px !important;
30
+ font-weight: 500 !important;
31
+ color: rgb(255, 255, 255) !important;
32
+ line-height: 1 !important;
33
+ border-radius: 12px !important;
34
+ transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
35
+ box-shadow: none !important;
36
+ }
37
+ .gr-button-primary:hover{
38
+ z-index: 14;
39
+ height: 43px;
40
+ width: 130px;
41
+ left: 0px;
42
+ top: 0px;
43
+ padding: 0px;
44
+ cursor: pointer !important;
45
+ background: none rgb(66, 133, 244) !important;
46
+ border: none !important;
47
+ text-align: center !important;
48
+ font-family: Poppins !important;
49
+ font-size: 14px !important;
50
+ font-weight: 500 !important;
51
+ color: rgb(255, 255, 255) !important;
52
+ line-height: 1 !important;
53
+ border-radius: 12px !important;
54
+ transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
55
+ box-shadow: rgb(0 0 0 / 23%) 0px 1px 7px 0px !important;
56
+ }
57
+ .hover\:bg-orange-50:hover {
58
+ --tw-bg-opacity: 1 !important;
59
+ background-color: rgb(229,225,255) !important;
60
+ }
61
+ .to-orange-200 {
62
+ --tw-gradient-to: rgb(37 56 133 / 37%) !important;
63
+ }
64
+ .from-orange-400 {
65
+ --tw-gradient-from: rgb(17, 20, 45) !important;
66
+ --tw-gradient-to: rgb(255 150 51 / 0);
67
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
68
+ }
69
+ .group-hover\:from-orange-500{
70
+ --tw-gradient-from:rgb(17, 20, 45) !important;
71
+ --tw-gradient-to: rgb(37 56 133 / 37%);
72
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
73
+ }
74
+ .group:hover .group-hover\:text-orange-500{
75
+ --tw-text-opacity: 1 !important;
76
+ color:rgb(37 56 133 / var(--tw-text-opacity)) !important;
77
+ }
78
+ """
79
+
80
+ demo = gr.Interface(fn=get_text_classification, inputs=[gr.Textbox(label="Input")], outputs=gr.Label(label="Classification"), title="Text Classification", examples=examples, css=css)
81
+ demo.launch()