ngocminhta commited on
Commit
53ef3bd
·
1 Parent(s): e3a4a85

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +22 -0
  2. app.py +7 -8
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+ ENV DEBIAN_FRONTEND=noninteractive
3
+
4
+ WORKDIR /app
5
+
6
+ COPY requirements.txt .
7
+
8
+ RUN apt-get update && \
9
+ apt-get install -y --no-install-recommends \
10
+ build-essential \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ RUN pip install --upgrade pip && \
14
+ pip install -r requirements.txt
15
+
16
+ COPY . .
17
+
18
+ EXPOSE 5000
19
+
20
+ ENV PORT=8000
21
+ EXPOSE $PORT
22
+ CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port $PORT"]
app.py CHANGED
@@ -23,8 +23,7 @@ app.add_middleware(
23
 
24
  class Opt:
25
  def __init__(self):
26
- self.model_name = "./unsup-simcse-xlm-roberta-base"
27
- self.model_path = "core/model.pth"
28
  self.database_path = "core/seen_db"
29
  self.embedding_dim = 768
30
  self.device_num = 1
@@ -40,12 +39,12 @@ def load_model_resources():
40
  global model, tokenizer, index, label_dict, is_mixed_dict
41
 
42
  model = TextEmbeddingModel(opt.model_name)
43
- state_dict = torch.load(opt.model_path, map_location=model.model.device)
44
- new_state_dict={}
45
- for key in state_dict.keys():
46
- if key.startswith('model.'):
47
- new_state_dict[key[6:]]=state_dict[key]
48
- model.load_state_dict(state_dict)
49
  tokenizer=model.tokenizer
50
 
51
  index = Indexer(opt.embedding_dim)
 
23
 
24
  class Opt:
25
  def __init__(self):
26
+ self.model_name = "ngocminhta/falcon-v1"
 
27
  self.database_path = "core/seen_db"
28
  self.embedding_dim = 768
29
  self.device_num = 1
 
39
  global model, tokenizer, index, label_dict, is_mixed_dict
40
 
41
  model = TextEmbeddingModel(opt.model_name)
42
+ # state_dict = torch.load(opt.model_path, map_location=model.model.device)
43
+ # new_state_dict={}
44
+ # for key in state_dict.keys():
45
+ # if key.startswith('model.'):
46
+ # new_state_dict[key[6:]]=state_dict[key]
47
+ # model.load_state_dict(state_dict)
48
  tokenizer=model.tokenizer
49
 
50
  index = Indexer(opt.embedding_dim)