parth parekh commited on
Commit
cc5ebd5
·
1 Parent(s): 3c4c0f5

distil bert was the best

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1,7 +1,7 @@
1
  from fastapi import FastAPI, HTTPException
2
  from pydantic import BaseModel
3
  import torch
4
- from transformers import BertTokenizer, BertForSequenceClassification
5
  from torch.nn.functional import softmax
6
 
7
  app = FastAPI(
@@ -14,8 +14,8 @@ app = FastAPI(
14
  class ContactDetector:
15
  def __init__(self):
16
  cache_dir = "/app/model_cache"
17
- self.tokenizer = BertTokenizer.from_pretrained('bert-base-uncased', cache_dir=cache_dir)
18
- self.model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2, cache_dir=cache_dir)
19
  self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
20
  self.model.to(self.device)
21
  self.model.eval()
 
1
  from fastapi import FastAPI, HTTPException
2
  from pydantic import BaseModel
3
  import torch
4
+ from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
5
  from torch.nn.functional import softmax
6
 
7
  app = FastAPI(
 
14
  class ContactDetector:
15
  def __init__(self):
16
  cache_dir = "/app/model_cache"
17
+ self.tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased', cache_dir=cache_dir)
18
+ self.model = DistilBertForSequenceClassification.from_pretrained('distilbert-base-uncased', num_labels=2, cache_dir=cache_dir)
19
  self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
20
  self.model.to(self.device)
21
  self.model.eval()