Spaces:
Sleeping
Sleeping
Commit
·
7d96a78
1
Parent(s):
61dfbf7
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
st.title("Correct Grammar with Transformers ")
|
4 |
st.write("")
|
5 |
st.write("Input your text here!")
|
6 |
|
@@ -16,7 +16,7 @@ torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
16 |
tokenizer = T5Tokenizer.from_pretrained('deep-learning-analytics/GrammarCorrector')
|
17 |
model = T5ForConditionalGeneration.from_pretrained('deep-learning-analytics/GrammarCorrector').to(torch_device)
|
18 |
|
19 |
-
def correct_grammar(input_text, num_return_sequences
|
20 |
batch = tokenizer([input_text], truncation=True, padding='max_length', max_length=len(input_text), return_tensors="pt").to(torch_device)
|
21 |
results = model.generate(**batch, max_length=len(input_text), num_beams=2, num_return_sequences=num_return_sequences, temperature=1.5)
|
22 |
return results
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
st.title("Correct Grammar with Transformers 🦄")
|
4 |
st.write("")
|
5 |
st.write("Input your text here!")
|
6 |
|
|
|
16 |
tokenizer = T5Tokenizer.from_pretrained('deep-learning-analytics/GrammarCorrector')
|
17 |
model = T5ForConditionalGeneration.from_pretrained('deep-learning-analytics/GrammarCorrector').to(torch_device)
|
18 |
|
19 |
+
def correct_grammar(input_text, num_return_sequences):
|
20 |
batch = tokenizer([input_text], truncation=True, padding='max_length', max_length=len(input_text), return_tensors="pt").to(torch_device)
|
21 |
results = model.generate(**batch, max_length=len(input_text), num_beams=2, num_return_sequences=num_return_sequences, temperature=1.5)
|
22 |
return results
|