Skip to content

Commit 4994345

Browse files
authored
Download models to tmp folders instead of working directory (#1012)
1 parent 8885fcb commit 4994345

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

examples/keras/document-denoiser/cortex.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
type: python
66
path: predictor.py
77
config:
8-
model: s3://cortex-examples/keras/document-denoiser
8+
model: s3://cortex-examples/keras/document-denoiser/model.h5
99
resize_shape: [540, 260]
1010
compute:
1111
cpu: 1

examples/keras/document-denoiser/predictor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ def __init__(self, config):
3939
# download the model
4040
bucket, key = re.match("s3://(.+?)/(.+)", config["model"]).groups()
4141
s3 = boto3.client("s3", config=Config(signature_version=UNSIGNED))
42-
model_name = "model.h5"
43-
s3.download_file(bucket, os.path.join(key, model_name), model_name)
42+
43+
model_path = os.path.join("/tmp/model.h5")
44+
s3.download_file(bucket, key, model_path)
4445

4546
# load the model
46-
self.model = load_model(model_name)
47+
self.model = load_model(model_path)
4748

4849
# resize shape (width, height)
4950
self.resize_shape = tuple(config["resize_shape"])

examples/tensorflow/license-plate-reader/cortex_lite.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
type: python
66
path: predictor_lite.py
77
config:
8-
yolov3: s3://cortex-examples/tensorflow/license-plate-reader/yolov3_keras
8+
yolov3: s3://cortex-examples/tensorflow/license-plate-reader/yolov3_keras/model.h5
99
yolov3_model_config: config.json
1010
compute:
1111
cpu: 1

examples/tensorflow/license-plate-reader/predictor_lite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def __init__(self, config):
1616
# download yolov3 model
1717
bucket, key = re.match("s3://(.+?)/(.+)", config["yolov3"]).groups()
1818
s3 = boto3.client("s3", config=Config(signature_version=UNSIGNED))
19-
model_name = "model.h5"
20-
s3.download_file(bucket, os.path.join(key, model_name), model_name)
19+
model_path = "/tmp/model.h5"
20+
s3.download_file(bucket, key, model_path)
2121

2222
# load yolov3 model
23-
self.yolov3_model = load_model(model_name)
23+
self.yolov3_model = load_model(model_path)
2424

2525
# get configuration for yolov3 model
2626
with open(config["yolov3_model_config"]) as json_file:

0 commit comments

Comments
 (0)