Spaces:
Sleeping
Sleeping
Suchinthana
commited on
Commit
•
a529649
1
Parent(s):
b09c49a
App code added
Browse files- app.py +20 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer
|
2 |
+
from transformers import pipeline
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Load tokenizer and generator
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained('google/mt5-base')
|
7 |
+
generator3 = pipeline(model='Suchinthana/MT5-Sinhala-Wikigen-Experimental', tokenizer=tokenizer)
|
8 |
+
|
9 |
+
# Define the function for Gradio to use
|
10 |
+
def generate_sinhala_text(prompt):
|
11 |
+
generated_text = generator3(prompt, do_sample=True, max_length=50)[0]['generated_text']
|
12 |
+
return generated_text
|
13 |
+
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=generate_sinhala_text,
|
16 |
+
inputs=gr.inputs.Textbox(),
|
17 |
+
outputs=gr.outputs.Textbox()
|
18 |
+
)
|
19 |
+
|
20 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
tokenizers
|
3 |
+
sentencepiece
|