Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,11 @@ model_name = "versae/byt5-base-finetuned-modernisa" # "versae/modernisa-pre"
|
|
6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
8 |
|
9 |
-
def modernisa(
|
10 |
-
|
|
|
|
|
|
|
11 |
text2text_generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
12 |
outputs = []
|
13 |
for line in lines:
|
@@ -32,6 +35,9 @@ porque el pensamiento creo"""
|
|
32 |
|
33 |
gr.Interface(
|
34 |
fn=modernisa,
|
35 |
-
inputs=
|
|
|
|
|
|
|
36 |
outputs=gr.outputs.HTML(label="Modern Spanish"),
|
37 |
).launch(inline=False)
|
|
|
6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
8 |
|
9 |
+
def modernisa(lines=None, file_obj=None):
|
10 |
+
if file_obj:
|
11 |
+
with open(file_obj.name) as file:
|
12 |
+
lines = file.read()
|
13 |
+
lines = [line for line in lines.strip().split('\n') if line.strip()]
|
14 |
text2text_generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
15 |
outputs = []
|
16 |
for line in lines:
|
|
|
35 |
|
36 |
gr.Interface(
|
37 |
fn=modernisa,
|
38 |
+
inputs=[
|
39 |
+
gr.inputs.Textbox(lines=12, label="Enter Old Spanish", default=random.choice(samples), optional=True),
|
40 |
+
gr.inputs.File(file_count="single", label="Or upload a plain text file (.txt)" type="file", optional=True),
|
41 |
+
],
|
42 |
outputs=gr.outputs.HTML(label="Modern Spanish"),
|
43 |
).launch(inline=False)
|