File tree Expand file tree Collapse file tree 8 files changed +41
-17
lines changed
tf_object_detection/tasks Expand file tree Collapse file tree 8 files changed +41
-17
lines changed Original file line number Diff line number Diff line change 4
4
pip :
5
5
name : " {{ item }}"
6
6
state : latest
7
- executable : pip3
7
+ executable : " {{ pip_version }} "
8
8
extra_args : --user
9
9
with_items :
10
10
- boto3
Original file line number Diff line number Diff line change 10
10
- name : Overwrite Configuration file from user-specific local configuration file
11
11
include_vars : ../config/config.local.yml
12
12
when : config_st.stat.exists == True
13
+
14
+ - name : Assert Python version properly set
15
+ assert :
16
+ that :
17
+ - " python_version == 2 or python_version == 3"
18
+ msg : " python_version must be set to either 2 or 3 in config/config.local.yml"
19
+
20
+ - name : Set variables according to Python version set to {{ python_version }}
21
+ set_fact :
22
+ pip_version : " {{ 'pip2' if python_version == 2 else 'pip3' }}"
23
+ python_name : " {{ 'python' if python_version == 2 else 'python3' }}"
Original file line number Diff line number Diff line change 124
124
-D WITH_OPENGL=ON
125
125
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
126
126
-D WITH_IPP=ON
127
- -D PYTHON_DEFAULT_EXECUTABLE=$(which python3 )
127
+ -D PYTHON_DEFAULT_EXECUTABLE=$(which {{ python_name }} )
128
128
-D INSTALL_PYTHON_EXAMPLES=ON
129
129
-D BUILD_PERF_TESTS=OFF
130
130
-D BUILD_TESTS=OFF
Original file line number Diff line number Diff line change 5
5
become : yes
6
6
7
7
- name : Install common packages (mostly python and pip)
8
- apt : name={{item}} state=latest
8
+ apt : name={{ item }} state=latest
9
9
with_items :
10
10
- aptitude
11
11
- colordiff
14
14
- python3-dev
15
15
- python-pip
16
16
- python3-pip
17
- - python3 -numpy
18
- - python3 -wheel
19
- - python3 -tk
17
+ - " {{ python_name }} -numpy"
18
+ - " {{ python_name }} -wheel"
19
+ - " {{ python_name }} -tk"
20
20
- unzip
21
21
- debconf
22
22
- debconf-utils
36
36
- include_tasks : tf_gpu_req.yml
37
37
when : tf_enable_gpu
38
38
39
- - name : Install latest tensorflow with native pip3 (no GPU support)
39
+ - name : Install latest tensorflow with native {{ pip_version }} package (no GPU support)
40
40
pip :
41
41
name : tensorflow
42
42
state : latest
43
- executable : pip3
43
+ executable : " {{ pip_version }} "
44
44
become : yes
45
45
when : not tf_build_from_source and not tf_enable_gpu
46
46
47
- - name : Install latest tensorflow with native pip3 (with GPU support)
47
+ - name : Install latest tensorflow with native {{ pip_version }} package (with GPU support)
48
48
pip :
49
49
name : tensorflow-gpu
50
50
state : latest
51
- executable : pip3
51
+ executable : " {{ pip_version }} "
52
52
become : yes
53
53
when : not tf_build_from_source and tf_enable_gpu
54
54
Original file line number Diff line number Diff line change 10
10
- protobuf-compiler
11
11
become : yes
12
12
13
- - name : Install dependencies through pip
13
+ - name : Install dependencies through {{ pip_version }}
14
14
pip :
15
15
name : " {{ item }}"
16
16
state : latest
17
- executable : pip3
17
+ executable : " {{ pip_version }} "
18
18
with_items :
19
19
- pillow
20
20
- lxml
32
32
- name : Install xlib required for screen capturing
33
33
apt : name={{ item }} state=latest
34
34
with_items :
35
- - python3 -xlib
35
+ - " {{ python_name }} -xlib"
36
36
- libx11-dev
37
37
become : yes
38
38
Original file line number Diff line number Diff line change 3
3
# # ATTENTION: Do not modify 'config.local.sample.yml' !! You should create a copy named 'config.local.yml' and modify that one !!
4
4
5
5
6
- # # Tensorflow
6
+ # # TensorFlow
7
7
8
8
tf_enable_gpu : false
9
9
@@ -15,6 +15,7 @@ tf_models_repo_name: tensorflow_models
15
15
tf_models_repo_url : tensorflow/models
16
16
tf_models_repo_branch : master
17
17
18
+
18
19
# # OpenCV
19
20
20
21
opencv_version : 3.3.1
@@ -23,3 +24,10 @@ opencv_contrib_repo_branch: 3.3.1
23
24
opencv_extra_repo_branch : 3.3.1
24
25
opencv_build_examples : OFF
25
26
opencv_force_rebuild : false
27
+
28
+
29
+ # # Python
30
+
31
+ # put either 2 for Python 2.7 or 3 for Python 3.5
32
+ # Note: When switching between versions, force rebuild of OpenCV and TensorFlow once (i.e., set opencv_force_rebuild to true)
33
+ python_version : 3
Original file line number Diff line number Diff line change 8
8
from contextlib import closing
9
9
import os
10
10
import sys
11
- from contextlib import suppress
12
11
from threading import Thread
13
- from queue import LifoQueue , Empty
12
+ if sys .version_info .major < 3 :
13
+ from Queue import LifoQueue , Empty
14
+ else :
15
+ from queue import LifoQueue , Empty
14
16
from time import sleep
15
17
from tempfile import gettempdir
16
18
@@ -30,8 +32,11 @@ def __init__(self):
30
32
31
33
def request (self , text ):
32
34
"""Clear queue (ignore it being empty) and add text, both non-blocking"""
33
- with suppress (Empty ):
35
+ # for Python 3.4+ this could be written as: with suppress(Empty): ... assuming: from contextlib import suppress
36
+ try :
34
37
self ._speak_queue .get_nowait ()
38
+ except Empty :
39
+ pass
35
40
self ._speak_queue .put_nowait (text )
36
41
37
42
def run (self ):
You can’t perform that action at this time.
0 commit comments