iyadalagha commited on
Commit
89a09b8
·
1 Parent(s): b18de50

Switch to SuperAnnotate/ai-detector for better accuracy

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -1,9 +1,13 @@
1
  from fastapi import FastAPI
2
- from transformers import pipeline
3
  from pydantic import BaseModel
 
4
 
5
  app = FastAPI()
6
- detector = pipeline("text-classification", model="roberta-base-openai-detector")
 
 
 
7
 
8
  class TextInput(BaseModel):
9
  text: str
 
1
  from fastapi import FastAPI
2
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
3
  from pydantic import BaseModel
4
+ import torch
5
 
6
  app = FastAPI()
7
+ model_name = "SuperAnnotate/ai-detector"
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
10
+ detector = pipeline("text-classification", model=model, tokenizer=tokenizer)
11
 
12
  class TextInput(BaseModel):
13
  text: str