Skip to content

Commit

Permalink
Utilise yaml file instead of json
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong1120 committed May 13, 2024
1 parent 8f44413 commit c51bdad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
19 changes: 0 additions & 19 deletions config/configuration.json

This file was deleted.

11 changes: 11 additions & 0 deletions config/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a list of video configurations
- video_url: "rtsp://example1.com/stream" # URL of the video
image_name: "cam1.png" # Name of the image
label: "label1" # Label of the video
model_key: "yolov8x" # Model key for the video
line_token: "token1" # Line token for notification
- video_url: "rtsp://example2.com/stream"
image_name: "cam2.png"
label: "label2"
model_key: "yolov8x"
line_token: "token2"
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
from logging import Logger
import json
import yaml
from datetime import datetime
from multiprocessing import Pool
import time
Expand Down Expand Up @@ -132,7 +132,7 @@ def run_multiple_streams(config_file: str, output_path: str = None):
"""
# Load configurations from file
with open(config_file, 'r') as file:
configurations = json.load(file)
configurations = yaml.safe_load(file)

# Process streams in parallel
num_processes = len(configurations)
Expand All @@ -143,7 +143,7 @@ def run_multiple_streams(config_file: str, output_path: str = None):

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run hazard detection on multiple video streams.')
parser.add_argument('--config', type=str, default='config/configuration.json', help='Configuration file path')
parser.add_argument('--config', type=str, default='config/configuration.yaml', help='Configuration file path')
parser.add_argument('--output', type=str, help='Path to save output images with timestamp in filename', required=False)
args = parser.parse_args()

Expand Down

0 comments on commit c51bdad

Please sign in to comment.