cccc commited on
Commit
dd6d97a
·
1 Parent(s): 3a71eee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -8
app.py CHANGED
@@ -1,9 +1,82 @@
1
  import gradio as gr
2
- #输入文本处理程序
3
- def greet(name):
4
- return "Hello " + name + "!"
5
- #接口创建函数
6
- #fn设置处理函数,inputs设置输入接口组件,outputs设置输出接口组件
7
- #fn,inputs,outputs都是必填函数
8
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ unmasker = pipeline('fill-mask', model='roberta-base') #bert-base-multilingual-cased') #bert-base-uncased')
5
+
6
+ def fill_mask(text):
7
+ unmasked = unmasker(text)
8
+ output = {}
9
+ for unmask in unmasked:
10
+ output[unmask["token_str"]] = unmask["score"]
11
+ return output
12
+
13
+ examples = [["Hello I'm a [MASK] model."], ["[MASK] is my favourite sports."]]
14
+
15
+ css = """
16
+ footer {display:none !important}
17
+ .output-markdown{display:none !important}
18
+ .gr-button-primary {
19
+ z-index: 14;
20
+ height: 43px;
21
+ width: 130px;
22
+ left: 0px;
23
+ top: 0px;
24
+ padding: 0px;
25
+ cursor: pointer !important;
26
+ background: none rgb(17, 20, 45) !important;
27
+ border: none !important;
28
+ text-align: center !important;
29
+ font-family: Poppins !important;
30
+ font-size: 14px !important;
31
+ font-weight: 500 !important;
32
+ color: rgb(255, 255, 255) !important;
33
+ line-height: 1 !important;
34
+ border-radius: 12px !important;
35
+ transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
36
+ box-shadow: none !important;
37
+ }
38
+ .gr-button-primary:hover{
39
+ z-index: 14;
40
+ height: 43px;
41
+ width: 130px;
42
+ left: 0px;
43
+ top: 0px;
44
+ padding: 0px;
45
+ cursor: pointer !important;
46
+ background: none rgb(37, 56, 133) !important;
47
+ border: none !important;
48
+ text-align: center !important;
49
+ font-family: Poppins !important;
50
+ font-size: 14px !important;
51
+ font-weight: 500 !important;
52
+ color: rgb(255, 255, 255) !important;
53
+ line-height: 1 !important;
54
+ border-radius: 12px !important;
55
+ transition: box-shadow 200ms ease 0s, background 200ms ease 0s !important;
56
+ box-shadow: rgb(0 0 0 / 23%) 0px 1px 7px 0px !important;
57
+ }
58
+ .hover\:bg-orange-50:hover {
59
+ --tw-bg-opacity: 1 !important;
60
+ background-color: rgb(229,225,255) !important;
61
+ }
62
+ .to-orange-200 {
63
+ --tw-gradient-to: rgb(37 56 133 / 37%) !important;
64
+ }
65
+ .from-orange-400 {
66
+ --tw-gradient-from: rgb(17, 20, 45) !important;
67
+ --tw-gradient-to: rgb(255 150 51 / 0);
68
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
69
+ }
70
+ .group-hover\:from-orange-500{
71
+ --tw-gradient-from:rgb(17, 20, 45) !important;
72
+ --tw-gradient-to: rgb(37 56 133 / 37%);
73
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
74
+ }
75
+ .group:hover .group-hover\:text-orange-500{
76
+ --tw-text-opacity: 1 !important;
77
+ color:rgb(37 56 133 / var(--tw-text-opacity)) !important;
78
+ }
79
+ """
80
+
81
+ demo = gr.Interface(fn=fill_mask, inputs=gr.Textbox(lines=1, label="Input"), outputs=gr.Label(label="Output"),title="Fill Mask | Data Science Dojo", theme="light", examples=examples, css=css)
82
+ demo.launch()