Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/yolov12.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Screenshot 2025-05-19 152029.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added carsonroad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions clusterdensity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import cv2 as cv
import numpy as np

img = cv.imread("imagewithbounds.jpg")

original = cv.imread("Screenshot 2025-05-19 152029.png")

# Taking a matrix of size 5 as the kernel
kernel = np.ones((5, 5), np.uint8)

img_erosion = cv.erode(img, kernel, iterations=1)

#Define structuring element.
boundary = img - img_erosion

img_dilate = cv.dilate(boundary, kernel, iterations = 2)

img_blur = cv.GaussianBlur(img,(5,5),10)

img_enhance = cv.Laplacian(boundary, cv.CV_64F, ksize=1)

# Create a mask for the color
mask = cv.inRange(img_dilate, (0,0,0), (0,255,0))

# Apply the mask to the original image
result = cv.bitwise_and(img,img, mask=mask)

result = cv.cvtColor(result, cv.COLOR_BGR2GRAY)

result = cv.bitwise_and(original,original, mask=result)

cv.imshow('result', result)

#components = cv.connectedComponentsWithStats(result)
#(totalcomponents,ID, pixelvalues, centroid) = components

#print(totalcomponents)
cv.waitKey(0)
cv.destroyAllWindows()
44 changes: 44 additions & 0 deletions drawbounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#program to manually draw boxes and find the amount of boxes within those bounds
import cv2 as cv

#manually draw circles on images
img = cv.imread("Screenshot 2025-05-19 152029.png")
drawing = False
mode = False
ix, iy = -1,-1
def draw_circle(event, x, y, flags, param):
global drawing,mode,ix,iy
if event == cv.EVENT_LBUTTONDOWN:
drawing = True
ix, iy = x, y
elif event == cv.EVENT_MOUSEMOVE:
if drawing:
if mode:
cv.rectangle(img, (ix,iy), (x, y), (0,255,0), -1)
else:
cv.circle(img, (x, y), 25, (0, 255, 0), -1)

elif event == cv.EVENT_LBUTTONUP:
drawing = False
if mode:
cv.rectangle(img, (ix, iy), (x, y), (0, 255, 0), -1)
else:
cv.circle(img, (x, y), 25, (0, 255, 0), -1)



cv.namedWindow(winname="test drawing")
cv.setMouseCallback("test drawing", draw_circle)
while True:
cv.imshow('test drawing',img)
k = cv.waitKey(1)
if k == ord('m'):
mode = not mode
elif k == ord('s'):
cv.imwrite("imagewithbounds.jpg", img)

#save new image



cv.destroyAllWindows()
Binary file added imagewithbounds.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 106 additions & 0 deletions runs/detect/train/args.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
task: detect
mode: train
model: yolov12n.yaml
data: coco.yaml
epochs: 600
time: null
patience: 100
batch: 256
imgsz: 640
save: true
save_period: -1
cache: false
device: '0'
workers: 8
project: null
name: train
exist_ok: false
pretrained: true
optimizer: auto
verbose: true
seed: 0
deterministic: true
single_cls: false
rect: false
cos_lr: false
close_mosaic: 10
resume: false
amp: true
fraction: 1.0
profile: false
freeze: null
multi_scale: false
overlap_mask: true
mask_ratio: 4
dropout: 0.0
val: true
split: val
save_json: false
save_hybrid: false
conf: null
iou: 0.7
max_det: 300
half: false
dnn: false
plots: true
source: null
vid_stride: 1
stream_buffer: false
visualize: false
augment: false
agnostic_nms: false
classes: null
retina_masks: false
embed: null
show: false
save_frames: false
save_txt: false
save_conf: false
save_crop: false
show_labels: true
show_conf: true
show_boxes: true
line_width: null
format: torchscript
keras: false
optimize: false
int8: false
dynamic: false
simplify: true
opset: null
workspace: null
nms: false
lr0: 0.01
lrf: 0.01
momentum: 0.937
weight_decay: 0.0005
warmup_epochs: 3.0
warmup_momentum: 0.8
warmup_bias_lr: 0.0
box: 7.5
cls: 0.5
dfl: 1.5
pose: 12.0
kobj: 1.0
nbs: 64
hsv_h: 0.015
hsv_s: 0.7
hsv_v: 0.4
degrees: 0.0
translate: 0.1
scale: 0.5
shear: 0.0
perspective: 0.0
flipud: 0.0
fliplr: 0.5
bgr: 0.0
mosaic: 1.0
mixup: 0.0
copy_paste: 0.1
copy_paste_mode: flip
auto_augment: randaugment
erasing: 0.4
crop_fraction: 1.0
cfg: null
tracker: botsort.yaml
save_dir: D:\yolov12\runs\detect\train
Binary file added tests/IMG24501.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from ultralytics import YOLO
import torch

model = YOLO('yolov12n.yaml')


# Train the model
results = model.train(
data='coco.yaml',
epochs=600,
batch=256,
imgsz=640,
scale=0.5, # S:0.9; M:0.9; L:0.9; X:0.9
mosaic=1.0,
mixup=0.0, # S:0.05; M:0.15; L:0.15; X:0.2
copy_paste=0.1, # S:0.15; M:0.4; L:0.5; X:0.6
device="0", #can change to "0,1,2,3" for multi gpu
)

# Evaluate model performance on the validation set
metrics = model.val()

# Perform object detection on an image
results = model("carsonroad.jpg")
results[0].show()
Binary file added ultralytics/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/data/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/data/__pycache__/base.cpython-38.pyc
Binary file not shown.
Binary file added ultralytics/data/__pycache__/build.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/data/__pycache__/utils.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/hub/__pycache__/auth.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/hub/__pycache__/utils.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/nn/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/nn/__pycache__/tasks.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/utils/__pycache__/dist.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/utils/__pycache__/loss.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/utils/__pycache__/ops.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ultralytics/utils/__pycache__/tal.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.