hk-bt-rnd commited on
Commit
0cdc4a5
·
1 Parent(s): c82d6b2

add dockerfile

Browse files
Files changed (3) hide show
  1. app.py +1 -1
  2. dockerfile +30 -0
  3. model/model_only.pt → model_only.pt +0 -0
app.py CHANGED
@@ -12,7 +12,7 @@ import torchvision.transforms.v2 as transforms
12
  MODEL_NAME = "distilbert/distilroberta-base"
13
  class_names = ['Action', 'Adventure', 'Comedy', 'Drama', 'Fantasy', 'Romance', 'Sci-Fi']
14
  tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
15
- cp = torch.load(r"model\model_only.pt", map_location="cpu")
16
  model_img = ImageModel(len(class_names))
17
  model_img.load_state_dict(cp['w_i'])
18
  model_text = TextModel(MODEL_NAME, len(class_names))
 
12
  MODEL_NAME = "distilbert/distilroberta-base"
13
  class_names = ['Action', 'Adventure', 'Comedy', 'Drama', 'Fantasy', 'Romance', 'Sci-Fi']
14
  tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
15
+ cp = torch.load(r"model_only.pt", map_location="cpu")
16
  model_img = ImageModel(len(class_names))
17
  model_img.load_state_dict(cp['w_i'])
18
  model_text = TextModel(MODEL_NAME, len(class_names))
dockerfile ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ WORKDIR /code
7
+
8
+ COPY ./requirements.txt ./requirements.txt
9
+
10
+ COPY ./model_only.pt ./model_only.pt
11
+
12
+ RUN pip install --no-cache-dir --upgrade -r ./requirements.txt
13
+
14
+ # Set up a new user named "user" with user ID 1000
15
+ RUN useradd -m -u 1000 user
16
+
17
+ # Switch to the "user" user
18
+ USER user
19
+
20
+ # Set home to the user's home directory
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/.local/bin:$PATH
23
+
24
+ # Set the working directory to the user's home directory
25
+ WORKDIR $HOME/app
26
+
27
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
28
+ COPY --chown=user . $HOME/app
29
+
30
+ CMD ["python", "app.py"]
model/model_only.pt → model_only.pt RENAMED
File without changes