Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import AutoTokenizer,
|
3 |
import torch
|
4 |
import spacy
|
5 |
import subprocess
|
@@ -29,7 +29,7 @@ tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst
|
|
29 |
model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english").to(device)
|
30 |
|
31 |
# Load grammar correction model from Hugging Face
|
32 |
-
grammar_corrector = pipeline("text2text-generation", model="
|
33 |
|
34 |
# AI detection function using DistilBERT
|
35 |
def detect_ai_generated(text):
|
@@ -78,7 +78,7 @@ def paraphrase_with_spacy_nltk(text):
|
|
78 |
|
79 |
return paraphrased_sentence
|
80 |
|
81 |
-
# Grammar correction function using
|
82 |
def correct_grammar(text):
|
83 |
corrected_text = grammar_corrector(text)[0]['generated_text']
|
84 |
return corrected_text
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
3 |
import torch
|
4 |
import spacy
|
5 |
import subprocess
|
|
|
29 |
model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english").to(device)
|
30 |
|
31 |
# Load grammar correction model from Hugging Face
|
32 |
+
grammar_corrector = pipeline("text2text-generation", model="pszemraj/flan-t5-large-grammar-synthesis", device=0 if torch.cuda.is_available() else -1)
|
33 |
|
34 |
# AI detection function using DistilBERT
|
35 |
def detect_ai_generated(text):
|
|
|
78 |
|
79 |
return paraphrased_sentence
|
80 |
|
81 |
+
# Grammar correction function using FLAN-T5
|
82 |
def correct_grammar(text):
|
83 |
corrected_text = grammar_corrector(text)[0]['generated_text']
|
84 |
return corrected_text
|