Views
No views yet

pip install -U yolov51import yolov5
2# from PIL import Image
3
4# load model
5model = yolov5.load('Gurveer05/moon-crater-boulder-detection-yolov5')
6
7# set model parameters
8model.conf = 0.25 # NMS confidence threshold
9model.iou = 0.45 # NMS IoU threshold
10model.agnostic = False # NMS class-agnostic
11model.multi_label = False # NMS multiple labels per box
12model.max_det = 1000 # maximum number of detections per image
13
14# set image
15img = 'path/to/image' # or use: img = Image.open('/path/to/image')
16
17# perform inference
18results = model(img) # add size=640 if needed
19
20# inference with test time augmentation
21results = model(img, augment=True)
22
23# parse results
24predictions = results.pred[0]
25boxes = predictions[:, :4] # x1, y1, x2, y2
26scores = predictions[:, 4]
27categories = predictions[:, 5]
28
29# show detection bounding boxes on image
30results.show()
31
32# save results into "results/" folder
33results.save(save_dir='results/')yolov5 train --data data.yaml --img 640 --batch 16 --weights Gurveer05/moon-crater-boulder-detection-yolov5 --epochs 10