File tree Expand file tree Collapse file tree 5 files changed +55
-8
lines changed Expand file tree Collapse file tree 5 files changed +55
-8
lines changed Original file line number Diff line number Diff line change
1
+ Dockerfile
2
+ README. *
3
+ .idea /
4
+ .git /
5
+ .gitignore
6
+ tests /
7
+ .pytest_cache
8
+ tests /
Original file line number Diff line number Diff line change
1
+ .idea /
2
+ .pytest_cache /
3
+ __pycache__ /
Original file line number Diff line number Diff line change
1
+ language : python
2
+ python :
3
+ - 3.6
4
+
5
+ services :
6
+ - docker
7
+
8
+ install :
9
+ - docker build -t max-inception-resnet-v2 .
10
+ - docker run -it -d -p 5000:5000 max-inception-resnet-v2
11
+ - sleep 30
12
+
13
+ before_script :
14
+ - pip install pytest requests
15
+
16
+ script :
17
+ - pytest tests/test.py
Original file line number Diff line number Diff line change 1
- FROM continuumio/miniconda3
1
+ FROM codait/max-base
2
2
3
3
ARG model_bucket=http://max-assets.s3-api.us-geo.objectstorage.softlayer.net/keras
4
4
ARG model_file=inception_resnet_v2.h5
5
5
6
6
WORKDIR /workspace
7
- RUN mkdir assets
8
- RUN wget -nv ${model_bucket}/${model_file} --output-document=/workspace/assets/${model_file}
7
+
8
+ RUN wget -nv --show-progress --progress=bar:force:noscroll ${model_bucket}/${model_file} --output-document=/workspace/assets/${model_file}
9
9
10
10
# Python package versions
11
11
ARG numpy_version=1.14.1
12
12
ARG tf_version=1.5.0
13
13
ARG keras_version=2.1.4
14
14
15
- RUN pip install --upgrade pip && \
16
- pip install numpy==${numpy_version} && \
15
+ RUN pip install numpy==${numpy_version} && \
17
16
pip install tensorflow==${tf_version} && \
18
17
pip install Pillow && \
19
18
pip install h5py && \
20
- pip install keras==${keras_version} && \
21
- pip install flask-restplus && \
22
- pip install ipython
19
+ pip install keras==${keras_version}
23
20
24
21
COPY . /workspace
25
22
Original file line number Diff line number Diff line change
1
+ import pytest
2
+ import requests
3
+
4
+
5
+ def test_response ():
6
+ model_endpoint = 'http://localhost:5000/model/predict'
7
+ file_path = 'assets/cat.jpg'
8
+
9
+ with open (file_path , 'rb' ) as file :
10
+ file_form = {'image' : (file_path , file , 'image/jpeg' )}
11
+ r = requests .post (url = model_endpoint , files = file_form )
12
+
13
+ assert r .status_code == 200
14
+ response = r .json ()
15
+ assert response ['status' ] == 'ok'
16
+ assert response ['predictions' ][0 ]['label_id' ] == 'n02123045'
17
+ assert response ['predictions' ][0 ]['label' ] == 'tabby'
18
+ assert response ['predictions' ][0 ]['probability' ] > 0.6
19
+
20
+
21
+ if __name__ == '__main__' :
22
+ pytest .main ([__file__ ])
You can’t perform that action at this time.
0 commit comments