> For the complete documentation index, see [llms.txt](https://htootayzaaung.gitbook.io/guardlens-real-time-weapon-detection-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://htootayzaaung.gitbook.io/guardlens-real-time-weapon-detection-system/getting-started.md).

# Getting Started

#### Project Directory Structure

Here is the structure of the project directory to help you navigate the files:

```plaintext
.
├── detectron2
│   └── Object_Detection
│       ├── Faster_RCNN(detectron2).ipynb
│       ├── output
│       │   ├── events.out.tfevents.1708238712.MSI.44966.0
│       │   ├── events.out.tfevents.1708898117.96d7b304deb9.10588.0
│       │   ├── inference
│       │   │   ├── coco_instances_results.json
│       │   │   └── instances_predictions.pth
│       │   ├── intruder_valid_coco_format.json
│       │   ├── intruder_valid_coco_format.json.lock
│       │   ├── last_checkpoint
│       │   └── metrics.json
│       └── results.txt
├── Gathering_Datasets
│   └── gather_data.py
├── README.md
├── Web_App_UI
│   ├── alert_images
│   │   ├── alert_0_1714327026.jpg
│   │   └── alert_4_1714327015.jpg
│   ├── app.py
│   ├── requirements.txt
│   ├── camera_testing
│   │   ├── camera_list.py
│   │   ├── test_webcam1.py
│   │   └── test_webcam.py
│   ├── detect.py
│   ├── face_blurring.py
│   ├── models
│   │   ├── Mediapipe
│   │   │   └── model.tflite
│   │   └── Yolov8
│   │       ├── object_detection.pt
│   │       └── object_segmentation.pt
│   ├── object_detection.py
│   ├── __pycache__
│   │   ├── face_blurring.cpython-311.pyc
│   │   ├── object_detection.cpython-311.pyc
│   │   └── utility_functions.cpython-311.pyc
│   ├── static
│   │   ├── css
│   │   │   └── styles.css
│   │   └── js
│   │       └── main.js
│   ├── templates
│   │   ├── alert_email.html
│   │   └── index.html
│   └── utility_functions.py
└── yolov8
    ├── Object_Detection
    │   ├── runs
    │   │   └── detect
    │   │       ├── predict
    │   │       │   ├── 003af63a783a1615_jpg.rf.a1604da0249e644b875324c60a0021a7.jpg
    │   │       │   ├── 0231d2f11eb7a483_jpg.rf.ab7f38f1316b341d3b58f7ee7e84beed.jpg
    │   │       │   └── ...
    │   │       └── train
    │   │           ├── args.yaml
    │   │           ├── confusion_matrix_normalized.png
    │   │           ├── confusion_matrix.png
    │   │           ├── events.out.tfevents.1715069234.cab5a3b51062.5982.0
    │   │           ├── F1_curve.png
    │   │           ├── labels_correlogram.jpg
    │   │           ├── labels.jpg
    │   │           ├── P_curve.png
    │   │           ├── PR_curve.png
    │   │           ├── R_curve.png
    │   │           ├── results.csv
    │   │           ├── results.png
    │   │           ├── train_batch0.jpg
    │   │           ├── train_batch1.jpg
    │   │           ├── train_batch2.jpg
    │   │           ├── train_batch33475.jpg
    │   │           ├── train_batch33476.jpg
    │   │           ├── train_batch33477.jpg
    │   │           ├── val_batch0_labels.jpg
    │   │           ├── val_batch0_pred.jpg
    │   │           ├── val_batch1_labels.jpg
    │   │           ├── val_batch1_pred.jpg
    │   │           ├── val_batch2_labels.jpg
    │   │           ├── val_batch2_pred.jpg
    │   │           └── weights
    │   │               ├── best.pt
    │   │               └── last.pt
    │   └── Weapon_Detection(YOLOv8).ipynb
    └── Object_Segmentation
        ├── runs
        │   └── segment
        │       ├── predict
        │       │   ├── 1014_jpg.rf.fd987b3c771cedec550b7f27d76df1af.jpg
        │       │   ├── 101_jpg.rf.16908c82e05c877ca5a3045916cd31a7.jpg
        │       │   ├── 1023_jpg.rf.e4e5fe6e70236045274dde4b5b2c253b.jpg
        │       │   └── ...
        │       └── train
        │           ├── args.yaml
        │           ├── BoxF1_curve.png
        │           ├── BoxP_curve.png
        │           ├── BoxPR_curve.png
        │           ├── BoxR_curve.png
        │           ├── confusion_matrix_normalized.png
        │           ├── confusion_matrix.png
        │           ├── events.out.tfevents.1715018725.d418ef87afe5.12865.0
        │           ├── labels_correlogram.jpg
        │           ├── labels.jpg
        │           ├── MaskF1_curve.png
        │           ├── MaskP_curve.png
        │           ├── MaskPR_curve.png
        │           ├── MaskR_curve.png
        │           ├── results.csv
        │           ├── results.png
        │           ├── train_batch0.jpg
        │           ├── train_batch1.jpg
        │           ├── train_batch2.jpg
        │           ├── train_batch32045.jpg
        │           ├── train_batch32046.jpg
        │           ├── train_batch32047.jpg
        │           ├── val_batch0_labels.jpg
        │           ├── val_batch0_pred.jpg
        │           ├── val_batch1_labels.jpg
        │           ├── val_batch1_pred.jpg
        │           ├── val_batch2_labels.jpg
        │           ├── val_batch2_pred.jpg
        │           └── weights
        │               ├── best.pt
        │               └── last.pt
        └── Weapon_Segmentation(YOLOv8).ipynb
```

#### Setting up the Project Environment

To ensure the project runs smoothly, follow these steps to set up a Python virtual environment and install all required dependencies:

1. **Create a New Virtual Environment:**
   * Use Python to create a new virtual environment in your project directory:

     ```sh
     python3 -m venv guard_lens
     ```
2. **Activate the Virtual Environment:**
   * Activate the virtual environment by running:

     ```sh
     source guard_lens/bin/activate
     ```
3. **Install Required Packages:**
   * Install all dependencies listed in the `requirements.txt` file:

     ```sh
     pip install -r requirements.txt
     ```

This setup ensures that all necessary Python packages are installed within an isolated environment, reducing the risk of conflicts and issues.
