Spaces:
Sleeping
Sleeping
fixed issues
Browse files- app/main.py +3 -2
app/main.py
CHANGED
|
@@ -20,8 +20,10 @@ tokenizer = BertTokenizer.from_pretrained(
|
|
| 20 |
)
|
| 21 |
model.eval()
|
| 22 |
|
|
|
|
|
|
|
| 23 |
le = LabelEncoder()
|
| 24 |
-
le.classes_ = np.load(
|
| 25 |
|
| 26 |
class TextInput(BaseModel):
|
| 27 |
text: str
|
|
@@ -30,7 +32,6 @@ class TextInput(BaseModel):
|
|
| 30 |
def read_root():
|
| 31 |
return {"message": "FastAPI backend is live. Go to /docs to test."}
|
| 32 |
|
| 33 |
-
|
| 34 |
@app.post("/predict")
|
| 35 |
async def predict(data: TextInput):
|
| 36 |
inputs = tokenizer(data.text, return_tensors="pt", truncation=True, padding=True)
|
|
|
|
| 20 |
)
|
| 21 |
model.eval()
|
| 22 |
|
| 23 |
+
# Correct path to label_classes.npy
|
| 24 |
+
label_path = os.path.join(os.path.dirname(__file__), "label_classes.npy")
|
| 25 |
le = LabelEncoder()
|
| 26 |
+
le.classes_ = np.load(label_path, allow_pickle=True)
|
| 27 |
|
| 28 |
class TextInput(BaseModel):
|
| 29 |
text: str
|
|
|
|
| 32 |
def read_root():
|
| 33 |
return {"message": "FastAPI backend is live. Go to /docs to test."}
|
| 34 |
|
|
|
|
| 35 |
@app.post("/predict")
|
| 36 |
async def predict(data: TextInput):
|
| 37 |
inputs = tokenizer(data.text, return_tensors="pt", truncation=True, padding=True)
|