versae commited on
Commit
9328f46
1 Parent(s): 5c0d878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -6,9 +6,26 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
  model = T5ForConditionalGeneration.from_pretrained(model_name)
7
 
8
  def modernisa(inputs):
9
- lines = inputs.split('\n')
10
  text2text_generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
11
  outputs = text2text_generator(lines, max_length=150)
12
  return "\n".join(output["generated_text"] for output in outputs)
13
 
14
- gr.Interface(fn=modernisa, inputs=gr.inputs.Textbox(lines=12, label="Enter Old Spanish"), outputs="text").launch(inline=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  model = T5ForConditionalGeneration.from_pretrained(model_name)
7
 
8
  def modernisa(inputs):
9
+ lines = [line for line in inputs.strip().split('\n') if line.strip()]
10
  text2text_generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
11
  outputs = text2text_generator(lines, max_length=150)
12
  return "\n".join(output["generated_text"] for output in outputs)
13
 
14
+ sample = """Otra vez, Don Iuan, me dad,
15
+ y otras mil vezes los braços.
16
+ Otra, y otras mil sean lazos
17
+ de nuestra antigua amistad.
18
+ Como venis?
19
+ Yo me siento
20
+ tan alegre, tan vfano,
21
+ tan venturoso, tan vano,
22
+ que no podrà el pensamiento
23
+ encareceros jamàs
24
+ las venturas que posseo,
25
+ porque el pensamiento creo"""
26
+
27
+ gr.Interface(
28
+ fn=modernisa,
29
+ inputs=gr.inputs.Textbox(lines=12, label="Enter Old Spanish", default=sample),
30
+ outputs=gr.outputs.Textbox(lines=12, label="Modern Spanish"),
31
+ ).launch(inline=False)