Group03 commited on
Commit
24bff19
·
verified ·
1 Parent(s): d30d9c4

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +12 -0
  2. app.py +89 -0
  3. requirements.txt +5 -0
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Zero Shot Text Classification
3
+ emoji: 👀
4
+ colorFrom: purple
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 3.4.1
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
5
+
6
+ def zeroShotClassification(text_input, candidate_labels):
7
+ labels = [label.strip(' ') for label in candidate_labels.split(',')]
8
+ output = {}
9
+ prediction = classifier(text_input, labels)
10
+ for i in range(len(prediction['labels'])):
11
+ output[prediction['labels'][i]] = prediction['scores'][i]
12
+ return output
13
+
14
+ examples = [["One day I will see the world", "travel, live, die, future"]]
15
+
16
+ css = """
17
+ footer {display:none !important}
18
+ .output-markdown{display:none !important}
19
+ .gr-button-primary {
20
+ z-index: 14;
21
+ height: 43px;
22
+ width: 130px;
23
+ left: 0px;
24
+ top: 0px;
25
+ padding: 0px;
26
+ cursor: pointer !important;
27
+ background: none rgb(17, 20, 45) !important;
28
+ border: none !important;
29
+ text-align: center !important;
30
+ font-family: Poppins !important;
31
+ font-size: 14px !important;
32
+ font-weight: 500 !important;
33
+ color: rgb(255, 255, 255) !important;
34
+ line-height: 1 !important;
35
+ border-radius: 12px !important;
36
+ transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
37
+ box-shadow: none !important;
38
+ }
39
+ .gr-button-primary:hover{
40
+ z-index: 14;
41
+ height: 43px;
42
+ width: 130px;
43
+ left: 0px;
44
+ top: 0px;
45
+ padding: 0px;
46
+ cursor: pointer !important;
47
+ background: none rgb(66, 133, 244) !important;
48
+ border: none !important;
49
+ text-align: center !important;
50
+ font-family: Poppins !important;
51
+ font-size: 14px !important;
52
+ font-weight: 500 !important;
53
+ color: rgb(255, 255, 255) !important;
54
+ line-height: 1 !important;
55
+ border-radius: 12px !important;
56
+ transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
57
+ box-shadow: rgb(0 0 0 / 23%) 0px 1px 7px 0px !important;
58
+ }
59
+ .hover\:bg-orange-50:hover {
60
+ --tw-bg-opacity: 1 !important;
61
+ background-color: rgb(229,225,255) !important;
62
+ }
63
+
64
+
65
+ .to-orange-200 {
66
+ --tw-gradient-to: rgb(37 56 133 / 37%) !important;
67
+ }
68
+
69
+ .from-orange-400 {
70
+ --tw-gradient-from: rgb(17, 20, 45) !important;
71
+ --tw-gradient-to: rgb(255 150 51 / 0);
72
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
73
+ }
74
+
75
+ .group-hover\:from-orange-500{
76
+ --tw-gradient-from:rgb(17, 20, 45) !important;
77
+ --tw-gradient-to: rgb(37 56 133 / 37%);
78
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
79
+ }
80
+ .group:hover .group-hover\:text-orange-500{
81
+ --tw-text-opacity: 1 !important;
82
+ color:rgb(37 56 133 / var(--tw-text-opacity)) !important;
83
+ }
84
+
85
+
86
+ """
87
+
88
+ demo = gr.Interface(fn=zeroShotClassification, inputs=[gr.Textbox(label="Input"), gr.Textbox(label="Candidate Labels")], outputs=gr.Label(label="Classification"), title="Zero Shot Text Classification | Data Science Dojo", examples=examples, css=css)
89
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ torch
3
+ timm
4
+ sentencepiece
5
+ transformers