diff --git a/cfg/yolov2-voc-1c.cfg b/cfg/yolov2-voc-1c.cfg new file mode 100644 index 000000000..415cfbe28 --- /dev/null +++ b/cfg/yolov2-voc-1c.cfg @@ -0,0 +1,258 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=8 +height=416 +width=416 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 80200 +policy=steps +steps=40000,60000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + + +####### + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[route] +layers=-9 + +[convolutional] +batch_normalize=1 +size=1 +stride=1 +pad=1 +filters=64 +activation=leaky + +[reorg] +stride=2 + +[route] +layers=-1,-4 + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=30 +activation=linear + + +[region] +anchors = 1.3221, 1.73145, 3.19275, 4.00944, 5.05587, 8.09892, 9.47112, 4.84053, 11.2364, 10.0071 +bias_match=1 +classes=1 +coords=4 +num=5 +softmax=1 +jitter=.3 +rescore=1 + +object_scale=5 +noobject_scale=1 +class_scale=1 +coord_scale=1 + +absolute=1 +thresh = .6 +random=1 diff --git a/cfg/yolov2-voc.cfg b/cfg/yolov2-voc.cfg new file mode 100644 index 000000000..dbf2de281 --- /dev/null +++ b/cfg/yolov2-voc.cfg @@ -0,0 +1,258 @@ +[net] +# Testing +batch=1 +subdivisions=1 +# Training +# batch=64 +# subdivisions=8 +height=416 +width=416 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.001 +burn_in=1000 +max_batches = 80200 +policy=steps +steps=40000,60000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=1024 +size=3 +stride=1 +pad=1 +activation=leaky + + +####### + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[route] +layers=-9 + +[convolutional] +batch_normalize=1 +size=1 +stride=1 +pad=1 +filters=64 +activation=leaky + +[reorg] +stride=2 + +[route] +layers=-1,-4 + +[convolutional] +batch_normalize=1 +size=3 +stride=1 +pad=1 +filters=1024 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=125 +activation=linear + + +[region] +anchors = 1.3221, 1.73145, 3.19275, 4.00944, 5.05587, 8.09892, 9.47112, 4.84053, 11.2364, 10.0071 +bias_match=1 +classes=20 +coords=4 +num=5 +softmax=1 +jitter=.3 +rescore=1 + +object_scale=5 +noobject_scale=1 +class_scale=1 +coord_scale=1 + +absolute=1 +thresh = .6 +random=1 diff --git a/darkflow/utils/pascal_voc_clean_xml.py b/darkflow/utils/pascal_voc_clean_xml.py index 70eb3e0fc..f28d7388d 100644 --- a/darkflow/utils/pascal_voc_clean_xml.py +++ b/darkflow/utils/pascal_voc_clean_xml.py @@ -19,7 +19,11 @@ def pascal_voc_clean_xml(ANN, pick, exclusive = False): cur_dir = os.getcwd() os.chdir(ANN) annotations = os.listdir('.') - annotations = glob.glob(str(annotations)+'*.xml') + try: + annotations = glob.glob(str(annotations)+'*.xml') + except Exception: + annotations = glob.glob('*.xml') + size = len(annotations) for i, file in enumerate(annotations): @@ -76,4 +80,4 @@ def pascal_voc_clean_xml(ANN, pick, exclusive = False): print('Dataset size: {}'.format(len(dumps))) os.chdir(cur_dir) - return dumps \ No newline at end of file + return dumps diff --git a/generateXML_CSV.py b/generateXML_CSV.py new file mode 100644 index 000000000..9f1ae5ec4 --- /dev/null +++ b/generateXML_CSV.py @@ -0,0 +1,66 @@ +#--------------------------------------------------------------------- +# +# Creating Darkflow Annotations for dataset (Converting in XML format) +# +# Function = write_xml() +# +# By - Jatin Kumar Mandav +# +# Requires 9 arguments, and 2 default arguments if you wish to alter +# +# Arguments: +# Directory where to save the XML file +# Label Name of the Image +# Name of the Image +# Boundung Box x1 +# Boundung Box y1 +# Boundung Box x2 +# Boundung Box y2 +# Width of Image +# Height of Image +# Depth of Image or Channels value '3'(RGB) by default +# Pose of Image, "Unspecified" by default +# +#--------------------------------------------------------------------- + +from lxml import etree +import xml.etree.cElementTree as ET + +def write_xml(savedir, label_name, imagename, bboxx1, bboxy1, bboxx2, bboxy2, imgWidth, imgHeight, depth=3, pose="Unspecified"): + individual_images_read_from_csv = pd.read_csv(csvFile).values + + currentfolder = savedir.split("\\")[-1] + + for image in individual_images_read_from_csv: + + annotation = ET.Element("annotaion") + ET.SubElement(annotation, 'folder').text = str(currentfolder) + ET.SubElement(annotation, 'filename').text = str(imagename) + size = ET.SubElement(annotation, 'size') + ET.SubElement(size, 'width').text = str(imgWidth) + ET.SubElement(size, 'height').text = str(imgHeight) + ET.SubElement(size, 'depth').text = str(depth) + + ET.SubElement(annotation, 'segmented').text = '0' + + obj = ET.SubElement(annotation, 'object') + + ET.SubElement(obj, 'name').text = str(label_name) + ET.SubElement(obj, 'pose').text = str(pose) + ET.SubElement(obj, 'truncated').text = '0' + ET.SubElement(obj, 'difficult').text = '0' + + bbox = ET.SubElement(obj, 'bndbox') + + ET.SubElement(bbox, 'xmin').text = str(bboxx1) + ET.SubElement(bbox, 'ymin').text = str(bboxy1) + ET.SubElement(bbox, 'xmax').text = str(bboxx2) + ET.SubElement(bbox, 'ymax').text = str(bboxy2) + + xml_str = ET.tostring(annotation) + root = etree.fromstring(xml_str) + xml_str = etree.tostring(root, pretty_print=True) + + save_path = os.path.join(saveDir, imagename + ".xml") + with open(save_path, 'wb') as temp_xml: + temp_xml.write(xml_str)