diff --git a/README.dataset.txt b/README.dataset.txt new file mode 100644 index 00000000..1d3968f1 --- /dev/null +++ b/README.dataset.txt @@ -0,0 +1,6 @@ +# e_commerce_gun_detection > weapons_version +https://universe.roboflow.com/melody-nyea3/e_commerce_gun_detection + +Provided by a Roboflow user +License: CC BY 4.0 + diff --git a/README.roboflow.txt b/README.roboflow.txt new file mode 100644 index 00000000..fe65ce07 --- /dev/null +++ b/README.roboflow.txt @@ -0,0 +1,29 @@ + +e_commerce_gun_detection - v5 weapons_version +============================== + +This dataset was exported via roboflow.com on February 21, 2025 at 7:33 AM GMT + +Roboflow is an end-to-end computer vision platform that helps you +* collaborate with your team on computer vision projects +* collect & organize images +* understand and search unstructured image data +* annotate, and create datasets +* export, train, and deploy computer vision models +* use active learning to improve your dataset over time + +For state of the art Computer Vision training notebooks you can use with this dataset, +visit https://github.com/roboflow/notebooks + +To find over 100k other datasets and pre-trained models, visit https://universe.roboflow.com + +The dataset includes 9646 images. +Gun are annotated in YOLOv8 format. + +The following pre-processing was applied to each image: +* Auto-orientation of pixel data (with EXIF-orientation stripping) +* Resize to 640x640 (Stretch) + +No image augmentation techniques were applied. + + diff --git a/data.yaml b/data.yaml new file mode 100644 index 00000000..4ed54568 --- /dev/null +++ b/data.yaml @@ -0,0 +1,13 @@ +train: ../train/images +val: ../valid/images +test: ../test/images + +nc: 1 +names: ['weapon'] + +roboflow: + workspace: melody-nyea3 + project: e_commerce_gun_detection + version: 5 + license: CC BY 4.0 + url: https://universe.roboflow.com/melody-nyea3/e_commerce_gun_detection/dataset/5 \ No newline at end of file diff --git a/live_detection.py b/live_detection.py new file mode 100644 index 00000000..a0eb22eb --- /dev/null +++ b/live_detection.py @@ -0,0 +1,29 @@ +import torch +import sys +import cv2 + +try: + from ultralytics import YOLO + print("loading yolOv8") + + model = YOLO('runs/detect/train/weights/best.pt') + print("conf. threshold=50%") + model.predict(source=0, show=True, conf=0.55) +except Exception as e: + print(f"YOLOv8 failed=error: {e}") + print("Attempting to load YOLOv5 instead") + + try: + import os + if not os.path.exists("yolov5"): + print("Cloning yolov5 repo") + os.system("git clone https://github.com/ultralytics/yolov5.git") + + os.system("pip install -r yolov5/requirements.txt") + + print("Running yoloV5 live with conf. threshold = 50%") + os.system("python yolov5/detect.py --weights runs/detect/train/weights/best.pt --source 0 --conf 0.5 --save") + + except Exception as e2: + print(f"yoloV5 failed {e2}") + sys.exit("ErRor") diff --git a/tempCodeRunnerFile.py b/tempCodeRunnerFile.py new file mode 100644 index 00000000..8b614b03 --- /dev/null +++ b/tempCodeRunnerFile.py @@ -0,0 +1,30 @@ +import torch +import sys +import cv2 + +try: + from ultralytics import YOLO + print("loadimg YOLOv8") + model = YOLO('runs/detect/train/weights/best.pt') + + print("Running YOLOV8 live detection") + model.predict(source=0, show=True) + +except Exception as e: + print(f"YOLOv8 failed with error: {e}") + print("Attempting to load YOLOv5 instead") + + try: + import os + if not os.path.exists("yolov5"): + print("Cloning YOLOv5 repository") + os.system("git clone https://github.com/ultralytics/yolov5.git") + + os.system("pip install -r yolov5/requirements.txt") + + print("Running YOLOv5 live detection...") + os.system("python yolov5/detect.py --weights runs/detect/train/weights/best.pt --source 0 --save") + + except Exception as e2: + print(f"YOLOv5 also failed with error: {e2}") + sys.exit("Error: Both YOLOv8 and YOLOv5 failed. check setup.") diff --git a/yolo11n.pt b/yolo11n.pt new file mode 100644 index 00000000..45b273b4 Binary files /dev/null and b/yolo11n.pt differ diff --git a/yolov8s.pt b/yolov8s.pt new file mode 100644 index 00000000..90b4a2c7 Binary files /dev/null and b/yolov8s.pt differ