Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,13 @@ import torch
|
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
-
MODEL_NAME = "
|
| 9 |
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 11 |
-
model = AutoModelForSequenceClassification.from_pretrained(
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
LABELS = [
|
| 14 |
"breast_cancer",
|
|
@@ -28,10 +31,6 @@ LABELS = [
|
|
| 28 |
class Input(BaseModel):
|
| 29 |
text: str
|
| 30 |
|
| 31 |
-
@app.get("/")
|
| 32 |
-
def home():
|
| 33 |
-
return {"status": "Cancer Type Classifier is running!"}
|
| 34 |
-
|
| 35 |
@app.post("/predict")
|
| 36 |
def predict(data: Input):
|
| 37 |
inputs = tokenizer(data.text, return_tensors="pt", truncation=True)
|
|
@@ -45,3 +44,7 @@ def predict(data: Input):
|
|
| 45 |
"prediction": LABELS[label_id],
|
| 46 |
"confidence": confidence
|
| 47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
+
MODEL_NAME = "monologg/distilbiobert"
|
| 9 |
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 11 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 12 |
+
MODEL_NAME,
|
| 13 |
+
num_labels=12 # عدد أنواع السرطان (أنت تتحكم به)
|
| 14 |
+
)
|
| 15 |
|
| 16 |
LABELS = [
|
| 17 |
"breast_cancer",
|
|
|
|
| 31 |
class Input(BaseModel):
|
| 32 |
text: str
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
@app.post("/predict")
|
| 35 |
def predict(data: Input):
|
| 36 |
inputs = tokenizer(data.text, return_tensors="pt", truncation=True)
|
|
|
|
| 44 |
"prediction": LABELS[label_id],
|
| 45 |
"confidence": confidence
|
| 46 |
}
|
| 47 |
+
|
| 48 |
+
@app.get("/")
|
| 49 |
+
def home():
|
| 50 |
+
return {"status": "Model is running"}
|