doublelotus commited on
Commit
f48b8b0
·
1 Parent(s): de2a392

creating cache

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -1
  2. main.py +4 -0
Dockerfile CHANGED
@@ -6,7 +6,13 @@ COPY ./requirements.txt /code/requirements.txt
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
- RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
 
 
 
 
 
 
10
 
11
  COPY . .
12
 
 
6
 
7
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
+ RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
10
+
11
+ # Create the cache directory
12
+ RUN mkdir -p /code/transformers_cache
13
+
14
+ # Set the TRANSFORMERS_CACHE environment variable
15
+ ENV TRANSFORMERS_CACHE=/code/transformers_cache
16
 
17
  COPY . .
18
 
main.py CHANGED
@@ -1,7 +1,11 @@
 
1
  from flask import Flask, jsonify
2
  from flask_cors import CORS
3
  from transformers import pipeline
4
 
 
 
 
5
  app = Flask(__name__)
6
  CORS(app)
7
 
 
1
+ import os
2
  from flask import Flask, jsonify
3
  from flask_cors import CORS
4
  from transformers import pipeline
5
 
6
+ # Set the cache directory to a location with write permissions
7
+ os.environ['TRANSFORMERS_CACHE'] = './transformers_cache'
8
+
9
  app = Flask(__name__)
10
  CORS(app)
11