Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,8 @@ def build_vocab(file_path, tokenizer, max_size, min_freq):
|
|
37 |
|
38 |
|
39 |
|
|
|
|
|
40 |
def greet(text):
|
41 |
parser = argparse.ArgumentParser(description='Chinese Text Classification')
|
42 |
parser.add_argument('--word', default=False, type=bool, help='True for word, False for char')
|
@@ -100,9 +102,87 @@ def greet(text):
|
|
100 |
return classes[predic[0]]
|
101 |
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
|
108 |
|
|
|
37 |
|
38 |
|
39 |
|
40 |
+
|
41 |
+
|
42 |
def greet(text):
|
43 |
parser = argparse.ArgumentParser(description='Chinese Text Classification')
|
44 |
parser.add_argument('--word', default=False, type=bool, help='True for word, False for char')
|
|
|
102 |
return classes[predic[0]]
|
103 |
|
104 |
|
105 |
+
|
106 |
+
|
107 |
+
inputs = gr.inputs.Textbox(label="输入文本", placeholder="在这里输入文本")
|
108 |
+
outputs = gr.outputs.Textbox(label="输出结果", placeholder="åˆ†ç±»ç»“æžœå°†åœ¨æ¤æ˜¾ç¤º")
|
109 |
+
|
110 |
+
css = """
|
111 |
+
.gradio-input-wrapper {
|
112 |
+
margin-bottom: 20px;
|
113 |
+
}
|
114 |
+
|
115 |
+
.gradio-output-wrapper {
|
116 |
+
margin-top: 20px;
|
117 |
+
}
|
118 |
+
|
119 |
+
.gradio-interface {
|
120 |
+
max-width: 600px;
|
121 |
+
margin: 0 auto;
|
122 |
+
background-color: #f8f8f8;
|
123 |
+
padding: 20px;
|
124 |
+
border-radius: 10px;
|
125 |
+
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
|
126 |
+
}
|
127 |
+
|
128 |
+
.gradio-interface h1 {
|
129 |
+
font-size: 32px;
|
130 |
+
font-weight: bold;
|
131 |
+
text-align: center;
|
132 |
+
margin-bottom: 20px;
|
133 |
+
}
|
134 |
+
|
135 |
+
.gradio-input label, .gradio-output label {
|
136 |
+
display: block;
|
137 |
+
margin-bottom: 10px;
|
138 |
+
font-size: 18px;
|
139 |
+
font-weight: bold;
|
140 |
+
}
|
141 |
+
|
142 |
+
.gradio-input textarea, .gradio-output textarea {
|
143 |
+
width: 100%;
|
144 |
+
height: 120px;
|
145 |
+
padding: 10px;
|
146 |
+
border: none;
|
147 |
+
border-radius: 5px;
|
148 |
+
box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.1);
|
149 |
+
font-size: 16px;
|
150 |
+
line-height: 24px;
|
151 |
+
}
|
152 |
+
|
153 |
+
.gradio-output textarea {
|
154 |
+
background-color: #f8f8f8;
|
155 |
+
color: #333;
|
156 |
+
}
|
157 |
+
|
158 |
+
.gradio-btn {
|
159 |
+
display: inline-block;
|
160 |
+
padding: 12px 20px;
|
161 |
+
margin-top: 20px;
|
162 |
+
font-size: 18px;
|
163 |
+
font-weight: bold;
|
164 |
+
text-align: center;
|
165 |
+
color: #ffffff;
|
166 |
+
background-color: #1abc9c;
|
167 |
+
border: none;
|
168 |
+
border-radius: 5px;
|
169 |
+
cursor: pointer;
|
170 |
+
transition: background-color 0.2s;
|
171 |
+
}
|
172 |
+
|
173 |
+
.gradio-btn:hover {
|
174 |
+
background-color: #16a085;
|
175 |
+
}
|
176 |
+
"""
|
177 |
+
|
178 |
+
interface = gr.Interface(fn=classify_text, inputs=inputs, outputs=outputs, title="䏿–‡æ–‡æœ¬åˆ†ç±»å™¨", css=css)
|
179 |
+
|
180 |
+
interface.launch()
|
181 |
+
|
182 |
+
|
183 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text", title="text-classification app",
|
184 |
+
# layout="vertical", description="This is a demo for text classification.")
|
185 |
+
# demo.launch()
|
186 |
|
187 |
|
188 |
|