Spaces:
Runtime error
Runtime error
Fixing indents
Browse files
app.py
CHANGED
@@ -18,30 +18,34 @@ from string import punctuation
|
|
18 |
title = "HanmunRoBERTa Century Classifier"
|
19 |
description = "Century classifier for classical Chinese and Korean texts"
|
20 |
|
21 |
-
|
|
|
22 |
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
def inference(inputtext, model,
|
25 |
-
if
|
26 |
inputtext = strip_text(inputtext)
|
27 |
if model == "HanmunRoBERTa":
|
28 |
outlabel = hanmun_roberta(inputtext)
|
29 |
return outlabel
|
30 |
-
|
31 |
-
def strip_text(inputtext):
|
32 |
-
characters_to_remove = "ββ‘()γγ:\"γΒ·, ?γ" + punctuation
|
33 |
-
translating = str.maketrans('', '', characters_to_remove)
|
34 |
-
return inputtext.translate(translating)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
gr.Interface(
|
37 |
inference,
|
38 |
-
[gr.inputs.Textbox(label="Input text",lines=10),
|
39 |
gr.inputs.Dropdown(choices=["HanmunRoBERTa"],
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
gr.inputs.Checkbox(label="Remove punctuation", value=True),
|
44 |
-
],
|
45 |
[gr.outputs.Label(label="Output")],
|
46 |
examples=examples,
|
47 |
title=title,
|
|
|
18 |
title = "HanmunRoBERTa Century Classifier"
|
19 |
description = "Century classifier for classical Chinese and Korean texts"
|
20 |
|
21 |
+
# Load the HanmunRoBERTa model
|
22 |
+
hanmun_roberta = gr.Interface.load("huggingface/bdsl/HanmunRoBERTa")
|
23 |
|
24 |
+
def strip_text(inputtext):
|
25 |
+
characters_to_remove = "ββ‘()γγ:\"γΒ·, ?γ" + punctuation
|
26 |
+
translating = str.maketrans('', '', characters_to_remove)
|
27 |
+
return inputtext.translate(translating)
|
28 |
|
29 |
+
def inference(inputtext, model, strip_text_flag):
|
30 |
+
if strip_text_flag:
|
31 |
inputtext = strip_text(inputtext)
|
32 |
if model == "HanmunRoBERTa":
|
33 |
outlabel = hanmun_roberta(inputtext)
|
34 |
return outlabel
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
# Define some example inputs for your interface
|
37 |
+
examples = [["Example text 1", "HanmunRoBERTa", True],
|
38 |
+
["Example text 2", "HanmunRoBERTa", True]]
|
39 |
+
|
40 |
+
# Set up the Gradio interface
|
41 |
gr.Interface(
|
42 |
inference,
|
43 |
+
[gr.inputs.Textbox(label="Input text", lines=10),
|
44 |
gr.inputs.Dropdown(choices=["HanmunRoBERTa"],
|
45 |
+
type="value",
|
46 |
+
default="HanmunRoBERTa",
|
47 |
+
label="Model"),
|
48 |
+
gr.inputs.Checkbox(label="Remove punctuation", value=True)],
|
|
|
49 |
[gr.outputs.Label(label="Output")],
|
50 |
examples=examples,
|
51 |
title=title,
|