Spaces:
Sleeping
Sleeping
Commit
·
93ad138
0
Parent(s):
Initial commit
Browse files- __pycache__/app.cpython-313.pyc +0 -0
- app.py +14 -0
- requirements.txt +5 -0
__pycache__/app.cpython-313.pyc
ADDED
|
Binary file (1.04 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 10 |
+
|
| 11 |
+
@app.post("/predict")
|
| 12 |
+
def predict(input: TextInput):
|
| 13 |
+
result = detector(input.text)
|
| 14 |
+
return {"prediction": result[0]['label'], "score": result[0]['score']}
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|
| 3 |
+
fastapi
|
| 4 |
+
uvicorn
|
| 5 |
+
pydantic
|