Spaces:
Runtime error
Runtime error
Abinaya Mahendiran
commited on
Commit
·
5a923ef
1
Parent(s):
e4461ed
Updated app
Browse files- app.py +24 -30
- config.json +2 -2
app.py
CHANGED
@@ -54,44 +54,38 @@ if page == 'Text Generation' and data == 'Oscar':
|
|
54 |
st.header('Tamil text generation with GPT2')
|
55 |
st.markdown('A simple demo using gpt-2-tamil model trained on Oscar dataset!')
|
56 |
model, tokenizer = load_model(config[data])
|
57 |
-
# Set default options
|
58 |
-
prompt = st.selectbox('Examples', prompts, index=len(prompts) - 1)
|
59 |
-
if prompt == "Custom":
|
60 |
-
prompt_box = ""
|
61 |
-
else:
|
62 |
-
prompt_box = prompt
|
63 |
-
text = st.text_input(
|
64 |
-
'Add your custom text in Tamil',
|
65 |
-
"",
|
66 |
-
max_chars=1000)
|
67 |
-
max_len = st.slider('Length of the sentence to generate', 25, 300, 100)
|
68 |
-
gen_bt = st.button('Generate')
|
69 |
elif page == 'Text Generation' and data == "Oscar + Indic Corpus":
|
70 |
st.header('Tamil text generation with GPT2')
|
71 |
st.markdown('A simple demo using gpt-2-tamil model trained on Oscar + IndicNLP dataset')
|
72 |
model, tokenizer = load_model(config[data])
|
|
|
|
|
|
|
|
|
|
|
73 |
# Set default options
|
74 |
-
prompt = st.selectbox('Examples', prompts, index=
|
75 |
if prompt == "Custom":
|
76 |
-
prompt_box = ""
|
77 |
-
|
78 |
-
prompt_box = prompt
|
79 |
-
text = st.text_input(
|
80 |
'Add your custom text in Tamil',
|
81 |
"",
|
82 |
max_chars=1000)
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
gen_bt = st.button('Generate')
|
85 |
-
else:
|
86 |
-
st.title('Tamil News classification with Finetuned GPT2')
|
87 |
-
st.markdown('In progress')
|
88 |
|
89 |
-
# Generate text
|
90 |
-
if gen_bt:
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
54 |
st.header('Tamil text generation with GPT2')
|
55 |
st.markdown('A simple demo using gpt-2-tamil model trained on Oscar dataset!')
|
56 |
model, tokenizer = load_model(config[data])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
elif page == 'Text Generation' and data == "Oscar + Indic Corpus":
|
58 |
st.header('Tamil text generation with GPT2')
|
59 |
st.markdown('A simple demo using gpt-2-tamil model trained on Oscar + IndicNLP dataset')
|
60 |
model, tokenizer = load_model(config[data])
|
61 |
+
else:
|
62 |
+
st.title('Tamil News classification with Finetuned GPT2')
|
63 |
+
st.markdown('In progress')
|
64 |
+
|
65 |
+
if page == "Text Generation":
|
66 |
# Set default options
|
67 |
+
prompt = st.selectbox('Examples', prompts, index=0)
|
68 |
if prompt == "Custom":
|
69 |
+
prompt_box = "",
|
70 |
+
text = st.text_input(
|
|
|
|
|
71 |
'Add your custom text in Tamil',
|
72 |
"",
|
73 |
max_chars=1000)
|
74 |
+
else:
|
75 |
+
prompt_box = prompt
|
76 |
+
text = st.text_input(
|
77 |
+
'Selected example in Tamil',
|
78 |
+
prompt,
|
79 |
+
max_chars=1000)
|
80 |
+
max_len = st.slider('Select length of the sentence to generate', 25, 300, 100)
|
81 |
gen_bt = st.button('Generate')
|
|
|
|
|
|
|
82 |
|
83 |
+
# Generate text
|
84 |
+
if gen_bt:
|
85 |
+
try:
|
86 |
+
with st.spinner('Generating...'):
|
87 |
+
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
88 |
+
seqs = generator(prompt_box, max_length=max_len)[0]['generated_text']
|
89 |
+
st.write(seqs)
|
90 |
+
except Exception as e:
|
91 |
+
st.exception(f'Exception: {e}')
|
config.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
{
|
2 |
"models": ["Text Generation", "Text Classification"],
|
3 |
-
"Text Generation": ["Oscar", "Oscar +
|
4 |
"Text Classification": ["News Data"],
|
5 |
"Oscar": "flax-community/gpt-2-tamil",
|
6 |
-
"Oscar +
|
7 |
"examples": ["ஒரு ஊரிலே ஒரு காக்கைக்கு",
|
8 |
"அன்பிர்க்கும் உன்டோ அடைக்கும்",
|
9 |
"தெனாலி ராமன், ஒரு பெரிய விகடகவி"]
|
|
|
1 |
{
|
2 |
"models": ["Text Generation", "Text Classification"],
|
3 |
+
"Text Generation": ["Oscar", "Oscar + IndicNLP"],
|
4 |
"Text Classification": ["News Data"],
|
5 |
"Oscar": "flax-community/gpt-2-tamil",
|
6 |
+
"Oscar + IndicNLP": "abinayam/gpt-2-tamil",
|
7 |
"examples": ["ஒரு ஊரிலே ஒரு காக்கைக்கு",
|
8 |
"அன்பிர்க்கும் உன்டோ அடைக்கும்",
|
9 |
"தெனாலி ராமன், ஒரு பெரிய விகடகவி"]
|