updates
This commit is contained in:
parent
d884c33d21
commit
87c5e43e8c
14
detect.py
14
detect.py
|
@ -67,9 +67,9 @@ def detect(save_txt=False, save_img=False):
|
||||||
save_img = True
|
save_img = True
|
||||||
dataset = LoadImages(source, img_size=img_size, half=half)
|
dataset = LoadImages(source, img_size=img_size, half=half)
|
||||||
|
|
||||||
# Get classes and colors
|
# Get names and colors
|
||||||
classes = load_classes(parse_data_cfg(opt.data)['names'])
|
names = load_classes(opt.names)
|
||||||
colors = [[random.randint(0, 255) for _ in range(3)] for _ in range(len(classes))]
|
colors = [[random.randint(0, 255) for _ in range(3)] for _ in range(len(names))]
|
||||||
|
|
||||||
# Run inference
|
# Run inference
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
@ -108,7 +108,7 @@ def detect(save_txt=False, save_img=False):
|
||||||
# Print results
|
# Print results
|
||||||
for c in det[:, -1].unique():
|
for c in det[:, -1].unique():
|
||||||
n = (det[:, -1] == c).sum() # detections per class
|
n = (det[:, -1] == c).sum() # detections per class
|
||||||
s += '%g %ss, ' % (n, classes[int(c)]) # add to string
|
s += '%g %ss, ' % (n, names[int(c)]) # add to string
|
||||||
|
|
||||||
# Write results
|
# Write results
|
||||||
for *xyxy, conf, _, cls in det:
|
for *xyxy, conf, _, cls in det:
|
||||||
|
@ -117,7 +117,7 @@ def detect(save_txt=False, save_img=False):
|
||||||
file.write(('%g ' * 6 + '\n') % (*xyxy, cls, conf))
|
file.write(('%g ' * 6 + '\n') % (*xyxy, cls, conf))
|
||||||
|
|
||||||
if save_img or view_img: # Add bbox to image
|
if save_img or view_img: # Add bbox to image
|
||||||
label = '%s %.2f' % (classes[int(cls)], conf)
|
label = '%s %.2f' % (names[int(cls)], conf)
|
||||||
plot_one_box(xyxy, im0, label=label, color=colors[int(cls)])
|
plot_one_box(xyxy, im0, label=label, color=colors[int(cls)])
|
||||||
|
|
||||||
print('%sDone. (%.3fs)' % (s, time.time() - t))
|
print('%sDone. (%.3fs)' % (s, time.time() - t))
|
||||||
|
@ -154,8 +154,8 @@ def detect(save_txt=False, save_img=False):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path')
|
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='*.cfg path')
|
||||||
parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data file path')
|
parser.add_argument('--names', type=str, default='data/coco.names', help='*.names path')
|
||||||
parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file')
|
parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file')
|
||||||
parser.add_argument('--source', type=str, default='data/samples', help='source') # input file/folder, 0 for webcam
|
parser.add_argument('--source', type=str, default='data/samples', help='source') # input file/folder, 0 for webcam
|
||||||
parser.add_argument('--output', type=str, default='output', help='output folder') # output folder
|
parser.add_argument('--output', type=str, default='output', help='output folder') # output folder
|
||||||
|
|
4
test.py
4
test.py
|
@ -203,8 +203,8 @@ def test(cfg,
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(prog='test.py')
|
parser = argparse.ArgumentParser(prog='test.py')
|
||||||
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path')
|
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='*.cfg path')
|
||||||
parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data file path')
|
parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data path')
|
||||||
parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file')
|
parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file')
|
||||||
parser.add_argument('--batch-size', type=int, default=16, help='size of each image batch')
|
parser.add_argument('--batch-size', type=int, default=16, help='size of each image batch')
|
||||||
parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
|
parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
|
||||||
|
|
4
train.py
4
train.py
|
@ -419,8 +419,8 @@ if __name__ == '__main__':
|
||||||
parser.add_argument('--epochs', type=int, default=273) # 500200 batches at bs 16, 117263 images = 273 epochs
|
parser.add_argument('--epochs', type=int, default=273) # 500200 batches at bs 16, 117263 images = 273 epochs
|
||||||
parser.add_argument('--batch-size', type=int, default=16) # effective bs = batch_size * accumulate = 16 * 4 = 64
|
parser.add_argument('--batch-size', type=int, default=16) # effective bs = batch_size * accumulate = 16 * 4 = 64
|
||||||
parser.add_argument('--accumulate', type=int, default=4, help='batches to accumulate before optimizing')
|
parser.add_argument('--accumulate', type=int, default=4, help='batches to accumulate before optimizing')
|
||||||
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path')
|
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='*.cfg path')
|
||||||
parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data file path')
|
parser.add_argument('--data', type=str, default='data/coco2017.data', help='*.data path')
|
||||||
parser.add_argument('--multi-scale', action='store_true', help='adjust (67% - 150%) img_size every 10 batches')
|
parser.add_argument('--multi-scale', action='store_true', help='adjust (67% - 150%) img_size every 10 batches')
|
||||||
parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
|
parser.add_argument('--img-size', type=int, default=416, help='inference size (pixels)')
|
||||||
parser.add_argument('--rect', action='store_true', help='rectangular training')
|
parser.add_argument('--rect', action='store_true', help='rectangular training')
|
||||||
|
|
Loading…
Reference in New Issue