Spaces:
Running on Zero
Running on Zero
refactor: update predict function return type and remove obsolete test script
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ print("Model loaded successfully.")
|
|
| 15 |
|
| 16 |
@app.api(name="predict")
|
| 17 |
@spaces.GPU
|
| 18 |
-
def predict(text: str):
|
| 19 |
"""Detect PII in the given text and return aggregated spans."""
|
| 20 |
results = classifier(text)
|
| 21 |
|
|
|
|
| 15 |
|
| 16 |
@app.api(name="predict")
|
| 17 |
@spaces.GPU
|
| 18 |
+
def predict(text: str) -> list:
|
| 19 |
"""Detect PII in the given text and return aggregated spans."""
|
| 20 |
results = classifier(text)
|
| 21 |
|
test.py
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
-
import json
|
| 3 |
-
|
| 4 |
-
classifier = pipeline(
|
| 5 |
-
task="token-classification",
|
| 6 |
-
model="openai/privacy-filter",
|
| 7 |
-
aggregation_strategy="simple"
|
| 8 |
-
)
|
| 9 |
-
|
| 10 |
-
res = classifier("My name is Alice Smith and my email is alice@example.com.")
|
| 11 |
-
print(json.dumps(res, indent=2))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|