sashtech commited on
Commit
6f0ffd9
·
verified ·
1 Parent(s): 5cbaee8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -24,11 +24,11 @@ word_vectors = api.load("glove-wiki-gigaword-50")
24
  # Check for GPU and set the device accordingly
25
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
26
 
27
- # Load AI Detector model and tokenizer from Hugging Face (roberta-base-openai-detector)
28
- tokenizer_ai = AutoTokenizer.from_pretrained("roberta-base-openai-detector")
29
- model_ai = AutoModelForSequenceClassification.from_pretrained("roberta-base-openai-detector").to(device)
30
 
31
- # AI detection function using RoBERTa-based model
32
  def detect_ai_generated(text):
33
  inputs = tokenizer_ai(text, return_tensors="pt", truncation=True, max_length=512).to(device)
34
  with torch.no_grad():
@@ -63,13 +63,13 @@ def capitalize_sentences_and_nouns(text):
63
 
64
  return ' '.join(corrected_text)
65
 
66
- # Paraphrasing function using spaCy and NLTK
67
  def paraphrase_with_spacy_nltk(text):
68
  doc = nlp(text)
69
  paraphrased_words = []
70
 
71
  for token in doc:
72
- # Map spaCy POS tags to WordNet POS tags
73
  pos = None
74
  if token.pos_ in {"NOUN"}:
75
  pos = wordnet.NOUN
 
24
  # Check for GPU and set the device accordingly
25
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
26
 
27
+ # Load AI Detector model and tokenizer from Hugging Face (e.g., GPT-Neo)
28
+ tokenizer_ai = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-2.7B")
29
+ model_ai = AutoModelForSequenceClassification.from_pretrained("EleutherAI/gpt-neo-2.7B").to(device)
30
 
31
+ # AI detection function using GPT-Neo-based model
32
  def detect_ai_generated(text):
33
  inputs = tokenizer_ai(text, return_tensors="pt", truncation=True, max_length=512).to(device)
34
  with torch.no_grad():
 
63
 
64
  return ' '.join(corrected_text)
65
 
66
+ # Paraphrasing function using SpaCy and NLTK
67
  def paraphrase_with_spacy_nltk(text):
68
  doc = nlp(text)
69
  paraphrased_words = []
70
 
71
  for token in doc:
72
+ # Map SpaCy POS tags to WordNet POS tags
73
  pos = None
74
  if token.pos_ in {"NOUN"}:
75
  pos = wordnet.NOUN