lars76 / object-localization

Object localization in images using simple CNNs and Keras
MIT License
137 stars 60 forks source link

Empty train.csv and validation.csv files #1

Closed iamthealphamale closed 5 years ago

iamthealphamale commented 6 years ago

Hello Lars, I would consider myself as a beginner in CNNs and would be grateful if you could assist with the problem I have. I have downloaded dataset and put .jpg and .xml files in the dataset folder. I have decided to put 4 instances for now to test the localization but it didn't work. train.csv and validation.csv files that are generated at the beginning when running generate_dataset.py are empty. Do you have any suggestions on why it won't work for me?

Kind regards, Arseniy

lars76 commented 6 years ago

Hi, check whether you set the right path (DATASET_FOLDER) in generate_dataset.py. Did you use a new dataset or Oxford-IIIT? If you use a new dataset, you will have to change generate_dataset.py. The script train_model.py expects the following columns in the csv file: path, class_id, width, height, x0, y0, x1, y1

iamthealphamale commented 6 years ago

Yes, I pasted the path of the dataset folder and used original dataset for now. As an alternative, could you please upload train.csv and validation.csv here so I could have a look? I would really appreciate it!

emilianooddo commented 6 years ago

Hi Lars, I've the same problem of imthealphamale. why this problem? thanks a lot. Best regards.

lars76 commented 6 years ago

Maybe my installation instructions were not clear enough.

  1. wget http://www.robots.ox.ac.uk/~vgg/data/pets/data/images.tar.gz
  2. wget http://www.robots.ox.ac.uk/~vgg/data/pets/data/annotations.tar.gz
  3. tar xf images.tar.gz
  4. tar xf annotations.tar.gz
  5. mv annotations/xmls/* images/
  6. Change DATASET_FOLDER
  7. python3 generate_dataset.py (maybe also install imgaug if you want better results)

The file train.csv will now contain lines like this: /home/lars/Downloads/images/Abyssinian_1.jpg,1,600,400,173,72,265,158 /home/lars/Downloads/images/Abyssinian_10.jpg,1,375,500,72,105,288,291 ...

I hope now it works for you guys

emilianooddo commented 6 years ago

oh, yes..that's great! Now, it's work! Thank you so much, lars! last one thing, how I can use my gpu for training?How can I set it?

Best regards

lars76 commented 6 years ago

No problem, you can enter in the terminal python3 -c "from keras import backend as K; print(K.tensorflow_backend._get_available_gpus())" to check whether Keras uses your GPU. Otherwise you have to configure it. Normally, you don't have to set /device:GPU:0 manually.

dhuruvapriyan commented 6 years ago

use this script to change xml files to single .csv files:

code starts here

import os import glob import pandas as pd import xml.etree.ElementTree as ET

xml_list = [] for xml_file in glob.glob('C:/Users/-----/*.xml'): #enter the path of the xml folder print("hi") tree = ET.parse(xml_file) root = tree.getroot() for member in root.findall('object'): print("hi") value = (root.find('filename').text, int(root.find('size')[0].text), int(root.find('size')[1].text), member[0].text, int(member[4][0].text), int(member[4][1].text), int(member[4][2].text), int(member[4][3].text) ) xml_list.append(value)

column_name = ['filename', 'width', 'height', 'class', 'xmin', 'ymin', 'xmax', 'ymax'] xml_df = pd.DataFrame(xml_list, columns=column_name) xml_df.to_csv('train_test.csv', index=None) print('Successfully converted xml to csv.')

code ends here

laurasels commented 5 years ago

image

I get also an empty train.csv. Is this because the folder 'annotations' is not in the right directory? See image of my directories.


Okay it works! I had to move the annotations folder into the images folder. I used the commando 5. mv annotations/xmls/* images/ as in the instructions, but now it works!