From 3cadbda84071a1256d3c37687f2ef291fdd5974c Mon Sep 17 00:00:00 2001 From: BogGyver Date: Wed, 8 Apr 2020 23:46:43 -0400 Subject: [PATCH] tweaks and more tweaks --- SConstruct | 2 +- common/basedir.py | 4 ++++ ...itoring_model.keras => dmonitoring_model.keras2} | Bin models/{supercombo.keras => supercombo.keras2} | Bin selfdrive/camerad/cameras/camera_webcam.cc | 8 ++++---- selfdrive/manager.py | 3 ++- selfdrive/modeld/runners/keras_runner.py | 8 ++++++-- 7 files changed, 17 insertions(+), 8 deletions(-) rename models/{dmonitoring_model.keras => dmonitoring_model.keras2} (100%) rename models/{supercombo.keras => supercombo.keras2} (100%) diff --git a/SConstruct b/SConstruct index 50b7b9108db45b..04c2033cf8211f 100644 --- a/SConstruct +++ b/SConstruct @@ -22,7 +22,7 @@ if arch == "aarch64": if is_tbp: webcam=True lenv = { - "LD_LIBRARY_PATH": '/usr/lib', + "LD_LIBRARY_PATH": '/usr/lib:/usr/local/lib/:/usr/lib/aarch64-linux-gnu', "PATH": os.environ['PATH'], "ANDROID_DATA": "/data", "ANDROID_ROOT": "/", diff --git a/common/basedir.py b/common/basedir.py index e928ded4c4d681..57eb5091525a01 100644 --- a/common/basedir.py +++ b/common/basedir.py @@ -2,9 +2,13 @@ BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) from common.android import ANDROID +WEBCAM = os.getenv("WEBCAM") is not None if ANDROID: PERSIST = "/persist" PARAMS = "/data/params" +elif WEBCAM: + PERSIST = "/data/params/persist" + PARAMS = "/data/params" else: PERSIST = os.path.join(BASEDIR, "persist") PARAMS = os.path.join(BASEDIR, "persist", "params") diff --git a/models/dmonitoring_model.keras b/models/dmonitoring_model.keras2 similarity index 100% rename from models/dmonitoring_model.keras rename to models/dmonitoring_model.keras2 diff --git a/models/supercombo.keras b/models/supercombo.keras2 similarity index 100% rename from models/supercombo.keras rename to models/supercombo.keras2 diff --git a/selfdrive/camerad/cameras/camera_webcam.cc b/selfdrive/camerad/cameras/camera_webcam.cc index e245a6a20af7ac..54b73a08e3ab5e 100644 --- a/selfdrive/camerad/cameras/camera_webcam.cc +++ b/selfdrive/camerad/cameras/camera_webcam.cc @@ -40,10 +40,10 @@ void camera_release_buffer(void *cookie, int buf_idx) { void open_gl_stream_def(CameraState * s, int video_id, int width, int height, char ** strm_def) { printf("OPENGLSTREAM"); std::string strm_template="v4l2src device=/dev/video%d ! video/x-raw,width=%d,height=%d,framerate=%d/1,format=YUY2 !" - "nvvidconv ! video/x-raw(memory:NVMM),format=I420 !" - "nvvidconv ! video/x-raw,format=BGRx !" - "videoconvert ! video/x-raw,format=BGR !" - "videoscale ! video/x-raw,width=%d,height=%d !" + " nvvidconv ! video/x-raw(memory:NVMM),format=I420 !" + " nvvidconv ! video/x-raw,format=BGRx !" + " videoconvert ! video/x-raw,format=BGR !" + " videoscale ! video/x-raw,width=%d,height=%d !" " appsink "; * strm_def = (char*)calloc(300,1); sprintf(*strm_def,strm_template.c_str(),video_id, width, height, s->fps, s->ci.frame_width, s->ci.frame_height); diff --git a/selfdrive/manager.py b/selfdrive/manager.py index 7ff0c3a8c3611e..f59dc6e3c8d487 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -559,7 +559,8 @@ def main(): os.environ['PARAMS_PATH'] = PARAMS # the flippening! - os.system('LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1') + if not WEBCAM: + os.system('LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1') # disable bluetooth os.system('service call bluetooth_manager 8') diff --git a/selfdrive/modeld/runners/keras_runner.py b/selfdrive/modeld/runners/keras_runner.py index 676008abd6f8d8..665886aec2d078 100755 --- a/selfdrive/modeld/runners/keras_runner.py +++ b/selfdrive/modeld/runners/keras_runner.py @@ -36,9 +36,13 @@ def run_loop(m): print(tf.__version__, file=sys.stderr) # limit gram alloc gpus = tf.config.experimental.list_physical_devices('GPU') - if len(gpus) > 0: - tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=2048)]) name = sys.argv[1].split('.keras')[0] + if name == "supercombo": + if len(gpus) > 0: + tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=2048)]) + else: + if len(gpus) > 0: + tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=1024)]) with open(f"{name}.model.keras", "r") as json_file: m = model_from_json(json_file.read()) m.load_weights(f"{name}.weights.keras")