Darkflow: How to change classes to a custom dataset VOC style?

Created on 4 May 2017  路  9Comments  路  Source: thtrieu/darkflow

I make a custom dataset VOC style with XML麓s but when i go to train appears the default VOC classes
How can i change it ?

cfg/yolo-voc.cfg parsing C:\anotattions
Parsing for ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'ca
t', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'potte
dplant', 'sheep', 'sofa', 'train', 'tvmonitor']
Traceback (most recent call last):
  File "flow", line 56, in <module>
    print('Enter training ...'); tfnet.train()

Most helpful comment

I would suggest printing annotations and seeing what the output is. You might have to make a modification in that file to process it.

For example, I had changed the line annotations = glob.glob(str(annotations)+'*.xml') to annotations = glob.glob('*.xml') in the darkflow\utils\pascal_voc_clean_xml.py file. But I might have been mistaken about the format of the annotations directory and so might have passed the argument in incorrectly.

All 9 comments

Changed the labels.txt file to hold the classes in your dataset.

I do it and i change the name of cfg and classes on cfg an i have this error

cfg/yolo-edi.cfg parsing C:\anotaciones
Parsing for ['rotor', 'pas', 'nacelle', 'torre']
Traceback (most recent call last):
  File "flow", line 56, in <module>
    print('Enter training ...'); tfnet.train()
  File "C:\darkflow-master\darkflow\net\flow.py", line 37, in train
    for i, (x_batch, datum) in enumerate(batches):
  File "C:\darkflow-master\darkflow\net\yolo\data.py", line 97, in shu
fle
    data = self.parse()
  File "C:\darkflow-master\darkflow\net\yolo\data.py", line 18, in par
e
    dumps = pascal_voc_clean_xml(ann, meta['labels'], exclusive)
  File "C:\darkflow-master\darkflow\utils\pascal_voc_clean_xml.py", li
e 22, in pascal_voc_clean_xml
    annotations = glob.glob(str(annotations)+'*.xml')
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\glob.py",
line 20, in glob
    return list(iglob(pathname, recursive=recursive))
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\glob.py",
line 54, in _iglob
    yield from glob1(dirname, basename)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\glob.py",
line 90, in glob1
    return fnmatch.filter(names, pattern)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\fnmatch.p
", line 52, in filter
    match = _compile_pattern(pat)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\fnmatch.p
", line 46, in _compile_pattern
    return re.compile(res).match
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\re.py", l
ne 224, in compile
    return _compile(pattern, flags)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\re.py", l
ne 293, in _compile
    p = sre_compile.compile(pattern, flags)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\sre_compi
e.py", line 536, in compile
    p = sre_parse.parse(p, flags)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\sre_parse
py", line 829, in parse
    p = _parse_sub(source, pattern, 0)
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\sre_parse
py", line 437, in _parse_sub
    itemsappend(_parse(source, state))
  File "C:\Users\imolinero\AppData\Local\Programs\Python\Python35\lib\sre_parse
py", line 575, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
sre_constants.error: bad character range r-3 at position 133

I would suggest printing annotations and seeing what the output is. You might have to make a modification in that file to process it.

For example, I had changed the line annotations = glob.glob(str(annotations)+'*.xml') to annotations = glob.glob('*.xml') in the darkflow\utils\pascal_voc_clean_xml.py file. But I might have been mistaken about the format of the annotations directory and so might have passed the argument in incorrectly.

Running the below command:

python3 ./flow --model cfg/yolo-new.cfg --train --dataset "~/VOCdevkit/VOC2007/JPEGImages" --annotation "~/VOCdevkit/VOC2007/Annotations" --batch 128 --epoch 100

Gives me the error:

Error: Annotation directory not found ~/VOCdevkit/VOC2007/Annotations .
Exception ignored in: >
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 587, in __del__
AttributeError: 'NoneType' object has no attribute 'TF_NewStatus'

I have the voc dataset downloaded in home directory.Any suggestions?

Are you sure the path is correct? For linux systems, your home directory would normally be /home/[username]/. Which means your path is probably /home/[username]/VOCdevkit/VOC2007/Annotations/

You can confirm by trying to cd or ls into the directory.

Note that you can also use a relative path.

Thanks man it was driving me crazy.
One last question if i may ask :P :now that i have trained some model, in order to test it in some testing data i just load it using --load -1 ?

Yep, that's how you load the checkpoint.

@denisli Do you also happen to know what the correct form of the path should be in Windows systems?Say i have my dataset folder in desktop.Thanks in advance.

http://stackoverflow.com/questions/607670/windows-shell-command-to-get-the-full-path-to-current-directory

Open up Command Prompt and type in cd. That will give you the path to whichever you need.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ManojPabani picture ManojPabani  路  4Comments

LeeroyHannigan picture LeeroyHannigan  路  4Comments

Kowasaki picture Kowasaki  路  4Comments

pribadihcr picture pribadihcr  路  5Comments

1NNcoder picture 1NNcoder  路  3Comments