JaySenpai commited on
Commit
85a9256
·
verified ·
1 Parent(s): 56f4c53

Update app/main.py

Browse files

model assign issue fixed

Files changed (1) hide show
  1. 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 # ✅ Dot notation
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)