Spaces:
Sleeping
Sleeping
Update app/main.py
Browse filesmodel assign issue fixed
- app/main.py +3 -2
app/main.py
CHANGED
|
@@ -15,7 +15,8 @@ app = FastAPI()
|
|
| 15 |
|
| 16 |
model = BertForSequenceClassification.from_pretrained(
|
| 17 |
"JaySenpai/bert-model",
|
| 18 |
-
cache_dir="/code/cache"
|
|
|
|
| 19 |
)
|
| 20 |
tokenizer = BertTokenizer.from_pretrained(
|
| 21 |
"JaySenpai/bert-model",
|
|
@@ -31,7 +32,7 @@ class TextInput(BaseModel):
|
|
| 31 |
|
| 32 |
@app.post("/predict")
|
| 33 |
async def predict(data: TextInput):
|
| 34 |
-
text = data.text
|
| 35 |
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 36 |
with torch.no_grad():
|
| 37 |
outputs = model(**inputs)
|
|
|
|
| 15 |
|
| 16 |
model = BertForSequenceClassification.from_pretrained(
|
| 17 |
"JaySenpai/bert-model",
|
| 18 |
+
cache_dir="/code/cache",
|
| 19 |
+
use_safetensors=True
|
| 20 |
)
|
| 21 |
tokenizer = BertTokenizer.from_pretrained(
|
| 22 |
"JaySenpai/bert-model",
|
|
|
|
| 32 |
|
| 33 |
@app.post("/predict")
|
| 34 |
async def predict(data: TextInput):
|
| 35 |
+
text = data.text
|
| 36 |
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 37 |
with torch.no_grad():
|
| 38 |
outputs = model(**inputs)
|