Spaces:
Sleeping
Sleeping
Add logs
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from transformers import pipeline
|
3 |
import os
|
|
|
|
|
4 |
|
5 |
# Set Hugging Face cache directory
|
6 |
os.environ["HF_HOME"] = "/app/.cache"
|
@@ -14,6 +16,8 @@ async def root():
|
|
14 |
|
15 |
@app.post("/predict")
|
16 |
async def predict(data: dict):
|
|
|
17 |
labels = ["Mathematics", "Language Arts", "Social Studies", "Science"]
|
18 |
result = classifier(data["text"], labels)
|
|
|
19 |
return {"label": result["labels"][0]}
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from transformers import pipeline
|
3 |
import os
|
4 |
+
import logging
|
5 |
+
|
6 |
|
7 |
# Set Hugging Face cache directory
|
8 |
os.environ["HF_HOME"] = "/app/.cache"
|
|
|
16 |
|
17 |
@app.post("/predict")
|
18 |
async def predict(data: dict):
|
19 |
+
logging.info(f"Received data: {data}")
|
20 |
labels = ["Mathematics", "Language Arts", "Social Studies", "Science"]
|
21 |
result = classifier(data["text"], labels)
|
22 |
+
logging.info(f"Prediction result: {result}")
|
23 |
return {"label": result["labels"][0]}
|