diff --git a/Makefile b/Makefile index e18bdec3..d978a08f 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ vio-edge-up: .PHONY: vio-up ## 🐳 Start all edge services (db, model_serving, orchestrator, interface) and hubs (monitoring, monitoring_db, labelizer) vio-up: - BUILDOS=${BUILDOS} docker compose --profile hub --profile edge up -d --build + BUILDOS=${BUILDOS} docker compose --profile hub --profile edge up -d .PHONY: vio-down ## ❌ Stop all services (model_serving, edge_orchestrator, ui) vio-down: diff --git a/deployment/edge/ansible/deploy_vio_on_edge.yml b/deployment/edge/ansible/deploy_vio_on_edge.yml index 4f528cb6..ddb89590 100644 --- a/deployment/edge/ansible/deploy_vio_on_edge.yml +++ b/deployment/edge/ansible/deploy_vio_on_edge.yml @@ -6,7 +6,7 @@ repo: https://github.com/octo-technology/VIO.git dest: "{{ REMOTE_VIO_DIR }}" single_branch: yes - version: main + version: demo-grosse-conf force: true - name: Remove config folder diff --git a/deployment/edge/ansible/files/docker-compose.template.yml b/deployment/edge/ansible/files/docker-compose.template.yml index 625df9dd..f9774582 100644 --- a/deployment/edge/ansible/files/docker-compose.template.yml +++ b/deployment/edge/ansible/files/docker-compose.template.yml @@ -30,7 +30,7 @@ services: SERVING_MODEL_URL: http://edge_model_serving:8501 GOOGLE_APPLICATION_CREDENTIALS: /edge_orchestrator/config/secrets/credentials.json BUCKET_NAME: tf-vio-bucket - ACTIVE_CONFIG_NAME: marker_classification_with_1_fake_camera + ACTIVE_CONFIG_NAME: duck_detection_gcp_with_2_usbcamera edge_interface: container_name: edge_interface diff --git a/deployment/edge/ansible/inventory.ini b/deployment/edge/ansible/inventory.ini index 61662bcc..2f13f5d3 100644 --- a/deployment/edge/ansible/inventory.ini +++ b/deployment/edge/ansible/inventory.ini @@ -1,16 +1,16 @@ [edge_1] -10.103.252.192 ansible_user=devkit ansible_password=devkit +172.23.26.98 ansible_user=octo ansible_password=devkit [edge_1:vars] EDGE_NAME="edge1" -IP_ADDRESS="10.103.252.192" +IP_ADDRESS="172.23.26.98" [edge_2] -10.103.253.2 ansible_user=devkit ansible_password=devkit +172.23.26.10 ansible_user=devkit ansible_password=devkit [edge_2:vars] EDGE_NAME="edge2" -IP_ADDRESS="10.103.253.2" +IP_ADDRESS="172.23.26.10" ; [localhost] ; 127.0.0.1 @@ -21,6 +21,6 @@ IP_ADDRESS="10.103.253.2" [all:vars] LOCAL_VIO_DIR={{ lookup('env', 'LOCAL_VIO_DIR') }} -REMOTE_VIO_DIR="/home/devkit/vio" +REMOTE_VIO_DIR="/home/{{ ansible_user }}/vio" GCP_VIO_BUCKET="tf-vio-bucket" GCP_VIO_PROJECT="acn-gcp-octo-sas" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 47ff10b2..326cd5b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,10 +23,10 @@ services: EDGE_ORCHESTRATOR_URL: http://edge_orchestrator:8000 profiles: [hub] - edge_interface: - extends: - file: edge_interface/edge_interface.yml - service: edge_interface + # edge_interface: + # extends: + # file: edge_interface/edge_interface.yml + # service: edge_interface hub_streamlit: container_name: hub_streamlit diff --git a/edge_model_serving/models/tflite/duck_detection/best_float32.tflite b/edge_model_serving/models/tflite/duck_detection/best_float32.tflite new file mode 100644 index 00000000..ff3f8d30 Binary files /dev/null and b/edge_model_serving/models/tflite/duck_detection/best_float32.tflite differ diff --git a/edge_model_serving/models/tflite/duck_detection/labels.txt b/edge_model_serving/models/tflite/duck_detection/labels.txt new file mode 100644 index 00000000..e105968e --- /dev/null +++ b/edge_model_serving/models/tflite/duck_detection/labels.txt @@ -0,0 +1,2 @@ +0 K0 +1 OK \ No newline at end of file diff --git a/edge_model_serving/tflite_serving/Dockerfile b/edge_model_serving/tflite_serving/Dockerfile index da78b215..ac3456b9 100644 --- a/edge_model_serving/tflite_serving/Dockerfile +++ b/edge_model_serving/tflite_serving/Dockerfile @@ -25,7 +25,7 @@ RUN pip install --no-cache-dir --upgrade pip setuptools COPY tflite_serving/pyproject.toml ./ COPY tflite_serving/src/ ./src COPY tflite_serving/pip.conf /opt/venv/pip.conf -COPY models/tflite/ $MODELS_PATH/tflite/ +# COPY models/tflite/ $MODELS_PATH/tflite/ RUN pip install --no-cache-dir . diff --git a/edge_model_serving/tflite_serving/tests/test_tflite_serving.py b/edge_model_serving/tflite_serving/tests/test_tflite_serving.py index ce69cd12..620d503d 100644 --- a/edge_model_serving/tflite_serving/tests/test_tflite_serving.py +++ b/edge_model_serving/tflite_serving/tests/test_tflite_serving.py @@ -27,10 +27,11 @@ def test_get_home_should_return_link_to_docs(self): assert actual_response.status_code == 200 assert actual_response.json() == expected_message - def test_get_models_should_return_4_models(self): + def test_get_models_should_return_6_models(self): # Given model_url = f"{self.base_url}/models" expected_models = [ + "duck_detection", "marker_quality_control", "mobilenet_ssd_v2_coco", "mobilenet_ssd_v2_face", diff --git a/edge_orchestrator/Dockerfile b/edge_orchestrator/Dockerfile index db26273d..1c365a1b 100644 --- a/edge_orchestrator/Dockerfile +++ b/edge_orchestrator/Dockerfile @@ -48,7 +48,7 @@ RUN pip install --no-cache-dir --upgrade pip setuptools COPY pip.conf /opt/venv/pip.conf COPY pyproject.toml ./ -COPY config ./config +# COPY config ./config COPY fake_images ./fake_images COPY model_labels ./model_labels COPY src/ ./src diff --git a/edge_orchestrator/config/data_gathering_with_1_usb_cam.json b/edge_orchestrator/config/data_gathering.json similarity index 89% rename from edge_orchestrator/config/data_gathering_with_1_usb_cam.json rename to edge_orchestrator/config/data_gathering.json index 3d663cc0..4ca9ef8d 100644 --- a/edge_orchestrator/config/data_gathering_with_1_usb_cam.json +++ b/edge_orchestrator/config/data_gathering.json @@ -1,5 +1,5 @@ { - "station_name": "data_gathering_with_1_usb_cam", + "station_name": "data_gathering", "camera_configs": { "camera_1": { "camera_id": "camera_1", diff --git a/edge_orchestrator/config/duck_detection_gcp_with_2_usbcamera.json b/edge_orchestrator/config/duck_detection_gcp_with_2_usbcamera.json new file mode 100644 index 00000000..18465ab6 --- /dev/null +++ b/edge_orchestrator/config/duck_detection_gcp_with_2_usbcamera.json @@ -0,0 +1,77 @@ +{ + "station_name": "duck_detection_gcp_with_2_usbcamera", + "camera_configs": { + "camera_1": { + "camera_id": "camera_1", + "camera_type": "usb", + "source_directory": "/dev/video0", + "position": "front", + "model_forwarder_config": { + "model_name": "duck_detection", + "model_type": "classification", + "expected_image_resolution": { + "width": 224, + "height": 224 + }, + "model_version": "1", + "class_names": [ + "KO", + "OK" + ], + "model_serving_url": "http://edge_model_serving:8501/", + "recreate_me": false + }, + "camera_rule_config": { + "camera_rule_type": "expected_label_rule", + "expected_class": "OK", + "recreate_me": false + }, + "recreate_me": false + }, + "camera_2": { + "camera_id": "camera_2", + "camera_type": "usb", + "source_directory": "/dev/video2", + "position": "front", + "camera_resolution": { + "width": 1366, + "height": 768 + }, + "model_forwarder_config": { + "model_name": "duck_detection", + "model_type": "classification", + "expected_image_resolution": { + "width": 224, + "height": 224 + }, + "model_version": "1", + "class_names": [ + "KO", + "OK" + ], + "model_serving_url": "http://edge_model_serving:8501/", + "recreate_me": false + }, + "camera_rule_config": { + "camera_rule_type": "expected_label_rule", + "expected_class": "OK", + "recreate_me": false + }, + "recreate_me": false + } + }, + "binary_storage_config": { + "storage_type": "gcp", + "bucket_name": "tf-vio-bucket" + }, + "metadata_storage_config": { + "storage_type": "gcp", + "bucket_name": "tf-vio-bucket" + }, + "item_rule_config": { + "item_rule_type": "min_threshold_ratio_rule", + "expected_decision": "OK", + "threshold": 1, + "recreate_me": false + } +} \ No newline at end of file diff --git a/edge_orchestrator/config/marker_classif_with_2_fake_cam.json b/edge_orchestrator/config/duck_detection_local_with_2_fakecamera.json similarity index 61% rename from edge_orchestrator/config/marker_classif_with_2_fake_cam.json rename to edge_orchestrator/config/duck_detection_local_with_2_fakecamera.json index 5492b9df..9062a40d 100644 --- a/edge_orchestrator/config/marker_classif_with_2_fake_cam.json +++ b/edge_orchestrator/config/duck_detection_local_with_2_fakecamera.json @@ -1,53 +1,63 @@ { - "station_name": "marker_classif_with_2_fake_cam", + "station_name": "duck_detection_local_with_2_fakecamera", "camera_configs": { "camera_1": { "camera_id": "camera_1", "camera_type": "fake", - "source_directory": "fake_images/marker_images", + "source_directory": "fake_images/ducks", "position": "front", "model_forwarder_config": { - "model_name": "marker_quality_control", + "model_name": "duck_detection", "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", "expected_image_resolution": { "width": 224, "height": 224 }, "model_version": "1", "class_names": [ - "OK", - "KO" - ] + "KO", + "OK" + ], + "model_serving_url": "http://edge_model_serving:8501/", + "recreate_me": false }, "camera_rule_config": { "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } + "expected_class": "OK", + "recreate_me": false + }, + "recreate_me": false }, "camera_2": { - "camera_id": "camera_2", + "camera_id": "camera_1", "camera_type": "fake", - "source_directory": "fake_images/marker_images", - "position": "back", + "source_directory": "fake_images/ducks", + "position": "front", + "camera_resolution": { + "width": 1366, + "height": 768 + }, "model_forwarder_config": { - "model_name": "marker_quality_control", + "model_name": "duck_detection", "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", "expected_image_resolution": { "width": 224, "height": 224 }, "model_version": "1", "class_names": [ - "OK", - "KO" - ] + "KO", + "OK" + ], + "model_serving_url": "http://edge_model_serving:8501/", + "recreate_me": false }, "camera_rule_config": { "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } + "expected_class": "OK", + "recreate_me": false + }, + "recreate_me": false } }, "binary_storage_config": { @@ -61,6 +71,7 @@ "item_rule_config": { "item_rule_type": "min_threshold_ratio_rule", "expected_decision": "OK", - "threshold": 1 + "threshold": 1, + "recreate_me": false } -} \ No newline at end of file +} diff --git a/edge_orchestrator/config/pin_detection_with_2_usb_cam.json b/edge_orchestrator/config/duck_detection_local_with_2_usbcamera.json similarity index 65% rename from edge_orchestrator/config/pin_detection_with_2_usb_cam.json rename to edge_orchestrator/config/duck_detection_local_with_2_usbcamera.json index fa1c63f5..1d3e7b96 100644 --- a/edge_orchestrator/config/pin_detection_with_2_usb_cam.json +++ b/edge_orchestrator/config/duck_detection_local_with_2_usbcamera.json @@ -1,5 +1,5 @@ { - "station_name": "pin_detection_with_2_usb_cam", + "station_name": "duck_detection_local_with_2_usbcamera", "camera_configs": { "camera_1": { "camera_id": "camera_1", @@ -7,47 +7,57 @@ "source_directory": "/dev/video0", "position": "front", "model_forwarder_config": { - "model_name": "pin_detection", + "model_name": "duck_detection", "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", "expected_image_resolution": { "width": 224, "height": 224 }, "model_version": "1", "class_names": [ - "OK", - "KO" - ] + "KO", + "OK" + ], + "model_serving_url": "http://edge_model_serving:8501/", + "recreate_me": false }, "camera_rule_config": { "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } + "expected_class": "OK", + "recreate_me": false + }, + "recreate_me": false }, "camera_2": { "camera_id": "camera_2", "camera_type": "usb", - "source_directory": "/dev/video4", - "position": "back", + "source_directory": "/dev/video2", + "position": "front", + "camera_resolution": { + "width": 1366, + "height": 768 + }, "model_forwarder_config": { - "model_name": "pin_detection", + "model_name": "duck_detection", "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", "expected_image_resolution": { "width": 224, "height": 224 }, "model_version": "1", "class_names": [ - "OK", - "KO" - ] + "KO", + "OK" + ], + "model_serving_url": "http://edge_model_serving:8501/", + "recreate_me": false }, "camera_rule_config": { "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } + "expected_class": "OK", + "recreate_me": false + }, + "recreate_me": false } }, "binary_storage_config": { @@ -61,6 +71,7 @@ "item_rule_config": { "item_rule_type": "min_threshold_ratio_rule", "expected_decision": "OK", - "threshold": 1 + "threshold": 1, + "recreate_me": false } } \ No newline at end of file diff --git a/edge_orchestrator/config/marker_classif_with_1_raspberry_cam.json b/edge_orchestrator/config/marker_classif_with_1_raspberry_cam.json deleted file mode 100644 index e18de87b..00000000 --- a/edge_orchestrator/config/marker_classif_with_1_raspberry_cam.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "station_name": "marker_classif_with_1_raspberry_cam", - "camera_configs": { - "camera_1": { - "camera_id": "camera_1", - "camera_type": "raspberry", - "position": "front", - "model_forwarder_config": { - "model_name": "marker_quality_control", - "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", - "expected_image_resolution": { - "width": 224, - "height": 224 - }, - "model_version": "1", - "class_names": [ - "OK", - "KO" - ] - }, - "camera_rule_config": { - "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } - } - }, - "binary_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "metadata_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "item_rule_config": { - "item_rule_type": "min_threshold_ratio_rule", - "expected_decision": "OK", - "threshold": 1 - } -} \ No newline at end of file diff --git a/edge_orchestrator/config/marker_classif_with_1_usb_cam.json b/edge_orchestrator/config/marker_classif_with_1_usb_cam.json deleted file mode 100644 index 6c13c57c..00000000 --- a/edge_orchestrator/config/marker_classif_with_1_usb_cam.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "station_name": "marker_classif_with_1_usb_cam", - "camera_configs": { - "camera_1": { - "camera_id": "camera_1", - "camera_type": "usb", - "source_directory": "/dev/video0", - "position": "front", - "model_forwarder_config": { - "model_name": "marker_quality_control", - "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", - "expected_image_resolution": { - "width": 224, - "height": 224 - }, - "model_version": "1", - "class_names": [ - "OK", - "KO" - ] - }, - "camera_rule_config": { - "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } - } - }, - "binary_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "metadata_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "item_rule_config": { - "item_rule_type": "min_threshold_ratio_rule", - "expected_decision": "OK", - "threshold": 1 - } -} \ No newline at end of file diff --git a/edge_orchestrator/config/mobilenet_ssd_v2_coco_with_2_usb_cam.json b/edge_orchestrator/config/mobilenet_ssd_v2_coco_with_2_usb_cam.json deleted file mode 100644 index f5a39ae5..00000000 --- a/edge_orchestrator/config/mobilenet_ssd_v2_coco_with_2_usb_cam.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "station_name": "mobilenet_ssd_v2_coco_with_2_usb_cam", - "camera_configs": { - "camera_1": { - "camera_id": "camera_1", - "camera_type": "usb", - "source_directory": "/dev/video0", - "position": "front", - "model_forwarder_config": { - "model_name": "yolo_coco_nano", - "model_type": "object_detection", - "model_serving_url": "http://edge_model_serving:8501/", - "expected_image_resolution": { - "width": 320, - "height": 320 - }, - "model_version": "1", - "class_names_filepath": "model_labels/coco_labels.txt" - }, - "camera_rule_config": { - "camera_rule_type": "min_nb_objects_rule", - "class_to_detect": "people", - "threshold": 1 - } - }, - "camera_2": { - "camera_id": "camera_2", - "camera_type": "usb", - "source_directory": "/dev/video4", - "position": "back", - "model_forwarder_config": { - "model_name": "yolo_coco_nano", - "model_type": "object_detection", - "model_serving_url": "http://edge_model_serving:8501/", - "expected_image_resolution": { - "width": 320, - "height": 320 - }, - "model_version": "1", - "class_names_filepath": "model_labels/coco_labels.txt" - }, - "camera_rule_config": { - "camera_rule_type": "min_nb_objects_rule", - "class_to_detect": "people", - "threshold": 1 - } - } - }, - "binary_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "metadata_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "item_rule_config": { - "item_rule_type": "min_threshold_ratio_rule", - "expected_decision": "OK", - "threshold": 1 - } -} \ No newline at end of file diff --git a/edge_orchestrator/config/pin_detection_with_1_usb_cam.json b/edge_orchestrator/config/pin_detection_with_1_usb_cam.json deleted file mode 100644 index a8829572..00000000 --- a/edge_orchestrator/config/pin_detection_with_1_usb_cam.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "station_name": "pin_detection_with_1_usb_cam", - "camera_configs": { - "camera_1": { - "camera_id": "camera_1", - "camera_type": "usb", - "source_directory": "/dev/video0", - "position": "front", - "model_forwarder_config": { - "model_name": "pin_detection", - "model_type": "classification", - "model_serving_url": "http://edge_model_serving:8501/", - "expected_image_resolution": { - "width": 224, - "height": 224 - }, - "model_version": "1", - "class_names": [ - "OK", - "KO" - ] - }, - "camera_rule_config": { - "camera_rule_type": "expected_label_rule", - "expected_class": "OK" - } - } - }, - "binary_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "metadata_storage_config": { - "storage_type": "filesystem", - "target_directory": "data_storage" - }, - "item_rule_config": { - "item_rule_type": "min_threshold_ratio_rule", - "expected_decision": "OK", - "threshold": 1 - } -} \ No newline at end of file diff --git a/edge_orchestrator/edge_orchestrator.yml b/edge_orchestrator/edge_orchestrator.yml index 82499595..f7504af8 100644 --- a/edge_orchestrator/edge_orchestrator.yml +++ b/edge_orchestrator/edge_orchestrator.yml @@ -8,10 +8,14 @@ services: BUILDOS: ${BUILDOS:-linux} volumes: - ./data_storage:/edge_orchestrator/data_storage + - ./config:/edge_orchestrator/config - /run/udev:/run/udev:ro # udev is the device manager for the Linux kernel, responsible for managing device nodes in the /dev directory dynamically ports: - 8000:8000 environment: SERVING_MODEL_URL: http://edge_model_serving:8501 + GOOGLE_APPLICATION_CREDENTIALS: /edge_orchestrator/config/secrets/credentials.json + BUCKET_NAME: tf-vio-bucket + ACTIVE_CONFIG_NAME: duck_detection_gcp_with_2_usbcamera privileged: true profiles: [edge] diff --git a/edge_orchestrator/fake_images/ducks/normal/0.jpg b/edge_orchestrator/fake_images/ducks/normal/0.jpg new file mode 100644 index 00000000..b686d2f0 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/normal/0.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/normal/1.jpg b/edge_orchestrator/fake_images/ducks/normal/1.jpg new file mode 100644 index 00000000..5a36a9cc Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/normal/1.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/normal/2.jpg b/edge_orchestrator/fake_images/ducks/normal/2.jpg new file mode 100644 index 00000000..5c03ad62 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/normal/2.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/normal/3.jpg b/edge_orchestrator/fake_images/ducks/normal/3.jpg new file mode 100644 index 00000000..ac96893b Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/normal/3.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/normal/4.jpg b/edge_orchestrator/fake_images/ducks/normal/4.jpg new file mode 100644 index 00000000..9fbe957c Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/normal/4.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/normal/5.jpg b/edge_orchestrator/fake_images/ducks/normal/5.jpg new file mode 100644 index 00000000..560e9617 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/normal/5.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/orange_nose/0.jpg b/edge_orchestrator/fake_images/ducks/orange_nose/0.jpg new file mode 100644 index 00000000..fc9c98d4 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/orange_nose/0.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/orange_nose/1.jpg b/edge_orchestrator/fake_images/ducks/orange_nose/1.jpg new file mode 100644 index 00000000..c63a26c3 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/orange_nose/1.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/orange_nose/2.jpg b/edge_orchestrator/fake_images/ducks/orange_nose/2.jpg new file mode 100644 index 00000000..10e71b83 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/orange_nose/2.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/orange_nose/3.jpg b/edge_orchestrator/fake_images/ducks/orange_nose/3.jpg new file mode 100644 index 00000000..efe9bfd4 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/orange_nose/3.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/orange_nose/4.jpg b/edge_orchestrator/fake_images/ducks/orange_nose/4.jpg new file mode 100644 index 00000000..eb1b9587 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/orange_nose/4.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/orange_nose/5.jpg b/edge_orchestrator/fake_images/ducks/orange_nose/5.jpg new file mode 100644 index 00000000..80a7092e Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/orange_nose/5.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/without_wing/0.jpg b/edge_orchestrator/fake_images/ducks/without_wing/0.jpg new file mode 100644 index 00000000..2cc5d61c Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/without_wing/0.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/without_wing/1.jpg b/edge_orchestrator/fake_images/ducks/without_wing/1.jpg new file mode 100644 index 00000000..c9c9d26a Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/without_wing/1.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/without_wing/2.jpg b/edge_orchestrator/fake_images/ducks/without_wing/2.jpg new file mode 100644 index 00000000..2fd3c8db Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/without_wing/2.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/without_wing/3.jpg b/edge_orchestrator/fake_images/ducks/without_wing/3.jpg new file mode 100644 index 00000000..b18be6c5 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/without_wing/3.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/without_wing/4.jpg b/edge_orchestrator/fake_images/ducks/without_wing/4.jpg new file mode 100644 index 00000000..1d05b10b Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/without_wing/4.jpg differ diff --git a/edge_orchestrator/fake_images/ducks/without_wing/5.jpg b/edge_orchestrator/fake_images/ducks/without_wing/5.jpg new file mode 100644 index 00000000..11492166 Binary files /dev/null and b/edge_orchestrator/fake_images/ducks/without_wing/5.jpg differ diff --git a/edge_orchestrator/src/edge_orchestrator/application/config/config_manager.py b/edge_orchestrator/src/edge_orchestrator/application/config/config_manager.py index df2e485e..b98a4022 100644 --- a/edge_orchestrator/src/edge_orchestrator/application/config/config_manager.py +++ b/edge_orchestrator/src/edge_orchestrator/application/config/config_manager.py @@ -14,7 +14,7 @@ class ConfigManager(metaclass=SingletonMeta): def __init__(self): self._station_configs: Dict[str, StationConfig] = {} - self._active_station_name: Optional[str] = os.getenv("ACTIVE_CONFIG_NAME", "marker_classif_with_2_fake_cam") + self._active_station_name: Optional[str] = os.getenv("ACTIVE_CONFIG_NAME", "duck_detection_gcp_with_2_usbcamera") self._logger = logging.getLogger(__name__) self._config_dir = Path(os.getenv("CONFIG_DIR", "config")).resolve() self._config_updated = False diff --git a/edge_orchestrator/src/edge_orchestrator/domain/models/model_forwarder/model_name.py b/edge_orchestrator/src/edge_orchestrator/domain/models/model_forwarder/model_name.py index a9aed4a0..63b24c48 100644 --- a/edge_orchestrator/src/edge_orchestrator/domain/models/model_forwarder/model_name.py +++ b/edge_orchestrator/src/edge_orchestrator/domain/models/model_forwarder/model_name.py @@ -8,3 +8,4 @@ class ModelName(str, Enum): mobilenet_ssd_v2_coco = "mobilenet_ssd_v2_coco" mobilenet_ssd_v2_face = "mobilenet_ssd_v2_face" yolo_coco_nano = "yolo_coco_nano" + duck_detection = "duck_detection" diff --git a/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/camera_factory.py b/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/camera_factory.py index f0ec2e6e..9855483c 100644 --- a/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/camera_factory.py +++ b/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/camera_factory.py @@ -23,11 +23,18 @@ def create_camera(self, camera_config: CameraConfig) -> ICamera: ) return RaspberryPiCamera(camera_config) - elif camera_config.camera_type in [CameraType.WEBCAM, CameraType.USB]: + elif camera_config.camera_type == CameraType.WEBCAM: from edge_orchestrator.infrastructure.adapters.camera.webcam_camera import ( WebcamCamera, ) return WebcamCamera(camera_config) + + elif camera_config.camera_type == CameraType.USB: + from edge_orchestrator.infrastructure.adapters.camera.usb_camera import ( + UsbCamera, + ) + + return UsbCamera(camera_config) else: raise ValueError(f"Camera type ({camera_config.camera_type}) is not supported.") diff --git a/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/usb_camera.py b/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/usb_camera.py new file mode 100644 index 00000000..72131d4d --- /dev/null +++ b/edge_orchestrator/src/edge_orchestrator/infrastructure/adapters/camera/usb_camera.py @@ -0,0 +1,24 @@ +import subprocess +import logging +from pathlib import Path + +from edge_orchestrator.domain.models.camera.camera_config import CameraConfig +from edge_orchestrator.domain.ports.camera.i_camera import ICamera +from edge_orchestrator.domain.models.image import Image + +class UsbCamera(ICamera): + def __init__(self, camera_config: CameraConfig): + self._camera_config = camera_config + self._logger = logging.getLogger(__name__) + self.src = self._camera_config.source_directory.as_posix() + + def capture(self) -> bytes: + resolution = "640x640" + img_save_path = f"{self.src}.jpg".replace("/", "") + cmd = f"fswebcam -r {resolution} -S 3 --jpeg 50 --save {img_save_path} -d {self.src}" + cmd_feedback = subprocess.run([cmd], shell=True) + self._logger.info(f"Camera exit code: {cmd_feedback.returncode}") + return Image(image_bytes=Path(img_save_path).open("rb").read()) + + def release(self): + pass \ No newline at end of file diff --git a/edge_streamlit/data_gathering.py b/edge_streamlit/data_gathering.py index fc6f9ebe..50a85987 100644 --- a/edge_streamlit/data_gathering.py +++ b/edge_streamlit/data_gathering.py @@ -12,7 +12,7 @@ # active_config = json.loads(requests.get(URL_ACTIVE_CONFIG).text) -data_gathering_active_config = "data_gathering_with_1_usb_cam" +data_gathering_active_config = "data_gathering" requests.post(url=f"{URL_ACTIVE_CONFIG}?station_name={data_gathering_active_config}") st.session_state.active_config = json.loads(requests.get(URL_ACTIVE_CONFIG).text)