Git Product home page Git Product logo

simrdwn's Introduction

SIMRDWN

Alt text

The Satellite Imagery Multiscale Rapid Detection with Windowed Networks (SIMRDWN) codebase combines some of the leading object detection algorithms into a unified framework designed to detect objects both large and small in overhead imagery. This work seeks to extend the YOLT modification of YOLO to include the TensorFlow Object Detection API. Therefore, one can train models and test on arbitrary image sizes with YOLO (versions 2 and 3), Faster R-CNN, SSD, or R-FCN.

For more information, see:

  1. Our arXiv paper: Satellite Imagery Multiscale Rapid Detection with Windowed Networks

  2. Our blog (e.g. 1, 2)

  3. Our original YOLT paper

  4. The original YOLT repository (now deprecated)


Running SIMRDWN


0. Installation

SIMRDWN is built to execute within a docker container on a GPU-enabled machine. The docker command creates an Ubuntu 16.04 image with CUDA 9.0, python 3.6, and tensorflow-gpu version 1.13.1.

  1. Clone this repository (e.g. to /simrdwn)

  2. Install nvidia-docker

  3. Build docker file.

     cd /simrdwn/docker
     nvidia-docker build --no-cache -t simrdwn .
    
  4. Spin up the docker container (see the docker docs for options)

     nvidia-docker run -it -v /simrdwn:/simrdwn --name simrdwn_container0 simrdwn
    
  5. Compile the Darknet C program for both YOLT2 and YOLT3.

     cd /simrdwn/yolt2
     make
     cd /simrdwn/yolt3
     make
    
  6. Get help on SIMRDWN options

     python /simrdwn/simrdwn/core/simrdwn.py --help
    

1. Prepare Training Data

1A. Create YOLT Format

Training data needs to be transformed to the YOLO format of training images in an "images" folder and bounding box labels in a "labels" folder. For example, an image "images/ex0.png" has a corresponding label "labels/ex0.txt". Labels are bounding boxes of the form

<object-class> <x> <y> <width> <height>

Where x, y, width, and height are relative to the image's width and height. Running a script such as /simrdwn/data_prep/parse_cowc.py_ extracts training windows of reasonable size (usually 416 or 544 pixels in extent) from large labeleled images of the COWC dataset. The script then transforms the labels corresponding to these windows into the correct format and creates a list of all training input images in /data/train_data/training_list.txt. We also need to define the object classes with a .pbtxt file, such as /data/training_data/class_labels_car.pbtxt. Class integers should be 1-indexed in the .pbtxt file.

1B. Create .tfrecord (optional)

If the tensorflow object detection API models are being run, we must transform the training data into the .tfrecord format. This is accomplished via the simrdwn/core/preprocess_tfrecords.py script.

python /simrdwn/core/preprocess_tfrecords.py \
    --image_list_file /simrdwn/data/cowc_labels_car_list.txt \
    --pbtxt_filename /simrdwn/data/class_labels_car.pbtxt \
    --outfile /simrdwn/data/cowc_labels_car_train.tfrecord \
    --outfile_val /simrdwn/data/cowc_labels_car_val.tfrecord \
    --val_frac 0.1

2. Train

We can train either YOLT models or tensorflow object detection API models. If we are using tensorflow, the config file may need to be updated in the /simrdwn/configs directory (further example config files reside here). Training can be run with commands such as:

# SSD vehicle search
python /simrdwn/core/simrdwn.py \
	--framework ssd \
	--mode train \
	--outname inception_v2_cowc \
	--label_map_path /simrdwn/data/class_labels_car.pbtxt \
	--tf_cfg_train_file _altered_v0/ssd_inception_v2_simrdwn.config \
	--train_tf_record cowc/cowc_train.tfrecord \
	--max_batches 30000 \
	--batch_size 16 

# YOLT vechicle search
python /simrdwn/core/simrdwn.py \
	--framework yolt2 \
	--mode train \
	--outname dense_cars \
	--yolt_cfg_file ave_dense.cfg  \
	--weight_file yolo.weights \
	--yolt_train_images_list_file cowc_yolt_train_list.txt \
	--label_map_path class_labels_car.pbtxt \
	--max_batches 30000 \
	--batch_size 64 \
	--subdivisions 16

3. Test

During the test phase, input images of arbitrary size are processed.

  1. Slice test images into the window size used in training.

  2. Run inference on windows with the desired model

  3. Stitch windows back together to create original test image

  4. Run non-max suppression on overlapping predictions

  5. Make plots of predictions (optional)

    # SSD vehicle search
    python /raid/local/src/simrdwn/src/simrdwn.py \
    	--framework ssd \
    	--mode test \
    	--outname inception_v2_cowc \
    	--label_map_path class_labels_car.pbtxt \
    	--train_model_path [ssd_train_path] \
    	--tf_cfg_train_file ssd_inception_v2_simrdwn.config \
    	--use_tfrecords=0 \
    	--testims_dir cowc/Utah_AGRC  \
    	--keep_test_slices 0 \
    	--test_slice_sep __ \
    	--test_make_legend_and_title 0 \
    	--edge_buffer_test 1 \
    	--test_box_rescale_frac 1 \
    	--plot_thresh_str 0.2 \
    	--slice_sizes_str 416 \
    	--slice_overlap 0.2 \
    	--alpha_scaling 1 \
    	--show_labels 0
    		
    # YOLT vehicle search
    python /raid/local/src/simrdwn/core/simrdwn.py \
    	--framework yolt2 \
    	--mode test \
    	--outname dense_cowc \
    	--label_map_path class_labels_car.pbtxt \
    	--train_model_path [yolt2_train_path] \
    	--weight_file ave_dense_final.weights \
    	--yolt_cfg_file ave_dense.cfg \
    	--testims_dir cowc/Utah_AGRC  \
    	--keep_test_slices 0 \
    	--test_slice_sep __ \
    	--test_make_legend_and_title 0 \
    	--edge_buffer_test 1 \
    	--test_box_rescale_frac 1 \
    	--plot_thresh_str 0.2 \
    	--slice_sizes_str 416 \
    	--slice_overlap 0.2 \
    	--alpha_scaling 1 \
    	--show_labels 1
    

    Outputs will be something akin to the images below. The alpha_scaling flag makes the bounding box opacity proportional to prediction confidence, and the show_labels flag prints the object class at the top of the bounding box. Alt text Alt text

If you plan on using SIMRDWN in your work, please consider citing YOLO, the TensorFlow Object Detection API, YOLT, and SIMRDWN.

simrdwn's People

Contributors

avanetten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simrdwn's Issues

Error when run data training preparation script from docker

i ran the script python /raid/simrdwn/core/prep_data_cowc.py
then i got this
Output :

('yolt_box_size (pixels):', 20.0)
('label_map_dict:', {1: 'car'})
('cat list:', ['car'])
('yolt cat str:', 'car')
('yolt_cat_dict:', {'car': 0})
('convert_dict:', {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7, 7: 8, 8: 9, 9: 10, 10: 11, 11: 12, 12: 13, 13: 14, 14: 15, 15: 16, 16: 17, 17: 18, 18: 19, 19: 20, 20: 21, 21: 22, 22: 23, 23: 24, 24: 25, 25: 26, 26: 27, 27: 28, 28: 29, 29: 30, 30: 31, 31:32, 32: 33, 33: 34, 34: 35, 35: 36, 36: 37, 37: 38, 38: 39, 39: 40, 40: 41, 41: 42, 42: 43, 43: 44, 44: 45, 45: 46, 46: 47, 47: 48, 48: 49, 49: 50, 50: 51, 51: 52, 52: 53, 53: 54, 54: 55, 55: 56, 56: 57, 57: 58, 58: 59, 59: 60, 60: 61, 61: 62, 62: 63,63: 64, 64: 65, 65: 66, 66: 67, 67: 68, 68: 69, 69: 70, 70: 71, 71: 72, 72: 73, 73: 74, 74: 75, 75: 76, 76: 77, 77: 78, 78: 79, 79: 80, 80: 81, 81: 82, 82: 83, 83: 84, 84: 85, 85: 86, 86: 87, 87: 88, 88: 89, 89: 90, 90: 91, 91: 92, 92: 93, 93: 94, 94:95, 95: 96, 96: 97, 97: 98, 98: 99, 99: 100})
('dtot:', '/raid/data/gdo152.ucllnl.org/cowc/datasets/ground_truth_sets/Potsdam_ISPRS')
Traceback (most recent call last):
  File "/raid/simrdwn/core/prep_data_cowc.py", line 142, in <module>
    files = os.listdir(dtot)
OSError: [Errno 2] No such file or directory: '/raid/data/gdo152.ucllnl.org/cowc/datasets/ground_truth_sets/Potsdam_ISPRS'

I followed every step from README.md. Is this expected or something wrong here?

calculating detection rate using validation data?

I successfully trained my own dataset using SIMRDWN. The detection result is good (assumption from detected images). Thanks @avanetten and others for their help.
Now I want to calculate detection rate and non-detection rate (other performance metric) using validation data. Is there any suggestion please?
Currently I used yolt2 as your documentation. How can I use yolt3?

Thanks

ModuleNotFoundError: No module named 'yolt_data_prep_funcs' ?

I am try to use parse_cows.py for my owndata. when I run the following command
python /simrdwn/core/parse_cowc.py, it gives the following error:

Traceback (most recent call last):
File "/simrdwn/simrdwn/core/parse_cowc.py", line 28, in
import yolt_data_prep_funcs
ModuleNotFoundError: No module named 'yolt_data_prep_funcs'

Is there any clue or idea about this error please?

Output weight location

This is not really an issue, but I don't know where to ask this, so my apology first.
I have one small question is that when I train using YOLT, is it automatically saved after some numbers of iterations or it can only be generated after running through all iterations?
Thank you.

Can i used other datasets to train simrdwn?

I tried to import and format SpaceNet building data using official utilities but failed horribly.
Is there any code from legacy project of yours that implemented SIMRDWN on SpaceNet dataset?
Can I see the code or can i work around the code in this repo (change from cocw to SpaceNet)?

Question about difference between "valid" mode and "test" mode

The code contains references to both modes "valid" and "test". Can you provide some clarification / context about when these modes would be used, and how to use each?

The readme has --mode valid under the examples for testing, so i'm not clear on the distinction between the two.

Thanks!

training my own data issue

@avanetten hey,thanks for your nice job!
I wanna train my own remote sensing datasethttp://captain.whu.edu.cn/DOTAweb/dataset.html using yolt3.There're 15 classes in my dataset,including
--large scales:roundabout,ground track field,soccerball field.They're large rectangles.
--small scales:planes,small veticles.They're Intensive small targets, neatly arranged.

Since objects of 15 classes have different scales,I try to cut the images to 416416 size,and many object boxes are splited.So CAN I CUT THE TRAINING IMAGES TO LARGER scales?I try 800800 but it seems that the input size should be 32*n??

If I want to train yolt3 with my dataset,should I must download the pretrain yolo weights in same input size?I visit https://pjreddie.com/darknet/yolo/ and find there're only 3 scales' yolo weights(320,416,608).So I must cut my images to (320,416,608) to match the pretrained weights?

Sorry but this is my first time using yolo, being explored and learning. I am trying to run yolt3 on my dataset. Also looking forward to some reply.:)

COWC Tutorial in Readme doesn't work

Hey Adam,
I'm having some trouble training a YOLT model with the COWC dataset. I followed the directions from the README file. The training portion appears to go smoothly:

...
Region Avg IOU: 0.605804, Class: 1.000000, Obj: 0.491915, No Obj: 0.002763, Avg Recall: 0.666667, count: 9
Region Avg IOU: 0.624894, Class: 1.000000, Obj: 0.422269, No Obj: 0.002980, Avg Recall: 0.789474, count: 38
Region Avg IOU: 0.723586, Class: 1.000000, Obj: 0.498320, No Obj: 0.003259, Avg Recall: 1.000000, count: 15
Region Avg IOU: 0.685469, Class: 1.000000, Obj: 0.517067, No Obj: 0.002437, Avg Recall: 0.857143, count: 7
Region Avg IOU: 0.692490, Class: 1.000000, Obj: 0.572129, No Obj: 0.002094, Avg Recall: 0.866667, count: 15
Region Avg IOU: 0.602785, Class: 1.000000, Obj: 0.428712, No Obj: 0.002838, Avg Recall: 0.791667,
...

But when I run the test command in the README file, I get no matches.

....
Length of time to run command: ./yolt/darknet -i 0 yolt2 valid /raid/simrdwn/results/valid_yolt_dense_cowc_2019_02_05_01-28-22/logs/yolt.cfg /raid/simrdwn/results/train_yolt_dense_cowc_2019_02_05_01-18-22/yolt_final.weights null 0 0.0 null /raid/simrdwn/results/valid_yolt_dense_cowc_2019_02_05_01-28-22 /raid/simrdwn/results/valid_yolt_dense_cowc_2019_02_05_01-28-22/valid_splitims_input_files.txt car 1 3 /raid/simrdwn/results/valid_yolt_dense_cowc_2019_02_05_01-28-22/logs/yolt_loss.txt 0.15 2>&1 | tee -a /raid/simrdwn/results/valid_yolt_dense_cowc_2019_02_05_01-28-22/logs/valid_yolt_dense_cowc_2019_02_05_01-28-22.log for 0 cutouts: 82.5787930489 seconds
valid_file: /raid/simrdwn/results/valid_yolt_dense_cowc_2019_02_05_01-28-22/car.txt
Length of time to run valid for 0 files = 187.060084105 seconds
Length of time to run refine_valid() 0.0210249423981 seconds
Length of time to run valid 187.485031128 seconds

I've attached a sample loss function graph - which doesn't look like the example. I'm not sure whether I should change some of the parameters or not. I haven't trained it for 30k batches, but I think there should be something appearing.

yolt_loss

Running inference in High Resolution GeoTiff

Dear Avanetten,

My purpose behind detecting objects in satellite imagery is to collect its spatial location after detection. Therefore, i wanted to whether we can run inferences over the high resolution geotiff? Furthermore, i want to run inference in satellite imagery of around 90 km2 to detect my objects of interest, is it possible to detect objects over such large area using SIMRDWN?

Thanks a lot & Cheers for such an amazing work. Looking forward to hear from you.

Best,
Suman

Formatting training files

Hey there,

I've run parse_cowc and _truth_df.csv has been created. I then assumed augment_refine should be run but the generated data doesn't seem to play well with that file.

Could you give me a clue as to the process here? The training portion of the documentation seems to be missing a step or two.

Thanks, Jared

Example YOLT format?

Could you provide an example of the YOLT format? It says that they have to be relative to the image's width and height but I am wondering which coordinate exactly is supposed to be the x and y. Is it the bottom-left? Or potentially the top-left?

And if it is the top-left, is the height specified in the negative, similar to how rows & cols are defined differently to cartesian x & y?

Thanks

How to generate airplane, boat and car tensorflow record file?

I tried to execute:
python /raid/simrdwn/core/preprocess_tfrecords.py --image_list_file /raid/simrdwn/data/cowc_yolt_train_list.txt --pbtxt_filename /raid/simrdwn/data/class_labels_airplane_boat_car.pbtxt --outfile /raid/simrdwn/data/labels_airplane_boat_car_train.tfrecord --val_frac 0.0

But that gives me an error:

image_file: /raid/simrdwn/training_datasets/cowc/images/slice_Toronto_ISPRS_03553_489_3912_544_544_0.png
os.path.exists(image_file? True
image_file: ```
/raid/simrdwn/training_datasets/cowc/images/slice_Toronto_ISPRS_03553_489_3912_544_544_0.png
image shape: (544, 544, 3)
Traceback (most recent call last):
File "/raid/simrdwn/core/preprocess_tfrecords.py", line 550, in
main()
File "/raid/simrdwn/core/preprocess_tfrecords.py", line 543, in main
convert_dict=convert_dict, verbose=verbose)
File "/raid/simrdwn/core/preprocess_tfrecords.py", line 395, in yolt_imlist_to_tf
verbose=verbose)
File "/raid/simrdwn/core/preprocess_tfrecords.py", line 245, in yolt_to_tf_example
cat_int_out = convert_dict[cat_int]
KeyError: 0.0

i am not sure how to extend the system for detecting more object types, like houses, etc.

NOTE: I just today started trying this cool project, so don't have knowledge what where is...

Detection works very well but confidence is very low

I've attached the inference results using the simrdwn. As you can see, the detection is quite good, but I'm not sure why (for most of the buildings at least) the confidence is so low. Strangely this is true for a training image as well which doesn't make sense. Do you have any ideas as to what could be a possible reason for this or is it just due to the standard problems like insufficient iterations or insufficient data?

atlanta_nadir7_catid_1030010003d22f00_732701_3731889_thresh 0 05
atlanta_nadir16_catid_1030010002649200_748451_3735939_thresh 0 05
atlanta_nadir27_catid_1030010003472200_734501_3743589_thresh 0 05

Labeling large tif images

Hello,
I am working on building detection from satellite images, and i think docker/yolt is the bestfit for my project,
but i work on large images (9351,9351) pixels,
so does this images should be an input for the training phase, or should segment it into smaller one?
If yes, can you propose any annotation tools (for labeling) can handle this large images?
Thanks you!

Getting an error when try to parse cowc dataset

The Error:
Executing get_gdf_tot_cowc()...
0 label_image_path: /home/hipstudents/cosmiq/cowc/datasets/ground_truth_sets/Utah_AGRC/12TVL240120_Annotated_Cars.png
0 image_path: /home/hipstudents/cosmiq/cowc/datasets/ground_truth_sets/Utah_AGRC/12TVL240120.png
Traceback (most recent call last):
File "parse_cowc.py", line 290, in
main()
File "parse_cowc.py", line 273, in main
verbose=verbose)
File "parse_cowc.py", line 212, in get_gdf_tot_cowc
yolt_box_size, verbose=verbose)
File "parse_cowc.py", line 157, in cowc_to_gdf
verbose=verbose)
File "parse_cowc.py", line 78, in gt_boxes_from_cowc_png
if len(label_locs) == 0:
TypeError: object of type 'zip' has no len()
........................................................

I don't know why this is happening.
I downloaded all data under Utah_AGRC Folder.

xView Dataset slicing

Will one of your functions properly slice the xView images as well as the geojson label file and keep them in tact for training? I have been reading the code and trying to come up with a solution for awhile now, but I haven't found one yet. The xView dataset is different that COWC since each bounding box is a different size for each object.

Any help or pointers would be greatly appreciated!

How to install SIMRDWN?

When I run the installation commands, it generates an error as below.

File "", line 2
nvidia-docker build --no-cache -t simrdwn .
^
SyntaxError: invalid syntax

I eagerly await your response. Thank you

Best,
Suman

Low Average Loss without any detection!

I have trained my network on my own data, using yolt2.
My data consist of 200 labeled images of building,
At the end of the training, the average loss attend the interval [0.7,1.5], which is considered acceptable as first step.
During test time, i have test a lot of images but without any detection (without any box!).
Note that all tested images was from training set, so i expected a good result.
NOTE: i have select the threshold to 0, but this don't change the result.

TRAIN COMMAND:
python /simrdwn/core/simrdwn.py
--framework yolt2
--mode train
--outname BUILDING
--yolt_cfg_file ave_dense.cfg
--weight_dir /simrdwn/yolt2/input_weights
--weight_file yolo.weights
--yolt_train_images_list_file ImagesList.txt
--label_map_path /simrdwn/data/class_labels_building.pbtxt
--nbands 3
--max_batches 10000
--batch_size 2
--subdivisions 1
--gpu 0

TEST COMMAND:
python /simrdwn/core/simrdwn.py
--framework yolt
--mode test
--outname BUILDING
--label_map_path '/simrdwn/data/class_labels_building.pbtxt' --train_model_path 'train_yolt2_BUILDING_2019_06_11_07-50-01'
--weight_file ave_dense_final.weights
--yolt_cfg_file ave_dense.cfg
--testims_dir 'images'
--keep_test_slices 0
--test_slice_sep __
--test_make_legend_and_title 0
--edge_buffer_test 1
--test_box_rescale_frac 1
--plot_thresh_str 0
--slice_sizes_str 416
--slice_overlap 0.2
--alpha_scaling 1
--show_labels 1

Example of Result:
F4__0_6972_416_416_0_9351_9351
F4__0_7304_416_416_0_9351_9351
F4__0_7636_416_416_0_9351_9351

Does any one have an idea for the solution?
Thank you!!

AVG value is very high during training yolt3?

The simrdwn is training with my own dataset (Sliced image size 544,544), but the avg values are very bad, like,
71: 1480.305054, 1145.447998 avg, 0.000000 rate, 3.784609 seconds, 4544 images Batch Num: 72 / 40000 72: 1478.472290, 1178.750488 avg, 0.000000 rate, 3.987175 seconds, 4608 images Batch Num: 73 / 40000 73: 1487.111450, 1209.586548 avg, 0.000000 rate, 4.056619 seconds, 4672 images Batch Num: 74 / 40000 74: 1490.246704, 1237.652588 avg, 0.000000 rate, 4.085837 seconds, 4736 images Batch Num: 75 / 40000 75: 1499.956299, 1263.882935 avg, 0.000000 rate, 4.212585 seconds, 4800 images Batch Num: 76 / 40000 76: 1506.523926, 1288.146973 avg, 0.000000 rate, 4.010417 seconds, 4864 images Batch Num: 77 / 40000 77: 1469.643677, 1306.296631 avg, 0.000000 rate, 3.884122 seconds, 4928 images Batch Num: 78 / 40000 78: 1539.585449, 1329.625488 avg, 0.000000 rate, 3.926301 seconds, 4992 images Batch Num: 79 / 40000 79: 1497.862549, 1346.449219 avg, 0.000000 rate, 4.035428 seconds, 5056 images Batch Num: 80 / 40000 80: 1490.782104, 1360.882568 avg, 0.000000 rate, 3.947680 seconds, 5120 images Batch Num: 81 / 40000 81: 1478.097534, 1372.604004 avg, 0.000000 rate, 3.813151 seconds, 5184 images Batch Num: 82 / 40000

My training command:

python3 /simrdwn2/simrdwn/core/simrdwn.py \ --framework yolt3 \ --mode train \ --outname dense_3class_vehicles \ --yolt_cfg_file yolov3_544.cfg \ --weight_dir /simrdwn2/simrdwn/yolt3/input_weights \ --weight_file yolov3.weights \ --yolt_train_images_list_file stone_yolt_train_list.txt \ --label_map_path /simrdwn2/simrdwn/data/class_labels_stone.pbtxt \ --nbands 3 \ --max_batches 40000 \ --batch_size 64 \ --subdivisions 16 \ --gpu 0

Would you give some advice please? I am waiting for your kind response. Thanks

Trained yolt stopped working?!

I'm scratching my head with this one. Back in March I had successfully trained Yolt using the COWC data and got some good test results on a separate data set.

Coming back a month later, I've tried to re-run the same config and can't get the same results! Probabilites are very low <0.01. The only thing that changed was a swap out of the Graphics card to upgrade to a Titan. Could this make a difference?

I was wondering if this was in anyway related to #26

Working with SIMRDWN in Google Colaboratory?

Has anyone used SIMRDWN with google collaboratory which offers free tesla k80 GPU for training and running inferences?

I look forward to hearing from you.

Best regards,

Suman

question about how to generate the appropriate cutout of the large image

Hey,avanetten
Sorry to trouble you again. I have trained the network, but the network didn't work, and I know where the question is. I use the whole large image as the input of the network, so the network didn't work. I read the paper again, and the papaer said the input should be the appropriate cutout of the large image.
The ''ReadMe.md" said :simrdwn/core/parse_cowc.py extracts training windows of reasonable size (usually 416 or 544 pixels in extent) from large labeleled images of the COWC dataset. but I didn't find the command to extract the windows. Could you tell me how to generate the appropriate cutout from the large image and the training windows should overlap or not,please?
Thank you very much and look forward to your replying

When I run the test command, I got an error

Creating args.inference_graph_path_tot: /simrdwn/results/train_yolt2_dense_3class_vehicles_2019_05_05_06-30-19/frozen_model/frozen_inference_graph.pb ...
Removing /simrdwn/results/train_yolt2_dense_3class_vehicles_2019_05_05_06-30-19/frozen_model/saved_model so we can overwrite it...
/simrdwn/results/train_yolt2_dense_3class_vehicles_2019_05_05_06-30-19
Traceback (most recent call last):
  File "/simrdwn/core/simrdwn.py", line 2234, in <module>
    main()
  File "/simrdwn/core/simrdwn.py", line 2226, in main
    execute(args)
  File "/simrdwn/core/simrdwn.py", line 1660, in execute
    tf_cfg_train_file=args.tf_cfg_train_file)
  File "/simrdwn/core/simrdwn.py", line 588, in tf_export_model_cmd
    num_max_tmp = np.max(nums_tmp)
  File "/opt/conda/envs/simrdwn2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2505, in amax
    initial=initial)
  File "/opt/conda/envs/simrdwn2/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation maximum which has no identity

In simrdwn.py
in 588 line

checkpoints_tmp = [ftmp for ftmp in os.listdir(trained_dir)
            if ftmp.startswith('model.ckpt')]
    #  print ("checkpoints tmp:", checkpoints_tmp)
    nums_tmp = [int(z.split('model.ckpt-')[-1].split('.')[0]) for z in checkpoints_tmp]
    #  print ("nums_tmp:", nums_tmp)
    num_max_tmp = np.max(nums_tmp)

then I found there is not model.ckpt file.
In the dictionary, it only contains those files:

ave_dense_10000_tmp.weights  ave_dense_20000_tmp.weights  ave_dense_5000_tmp.weights
ave_dense_1000_tmp.weights   ave_dense_25000_tmp.weights  ave_dense_final.weights
ave_dense_15000_tmp.weights  ave_dense_30000_tmp.weights  logs

what should i do?

FASTER_RCNN: TypeError: sequence item 0: expected string, int found

root@83d06eb5eb3c:/raid/simrdwn/data# python /raid/simrdwn/core/simrdwn.py --framework faster_rcnn --mode train --outname resnet101_3class_vehicles --label_map_path /simrdwn/data/class_labels_airplane_boat_car.pbtxt --tf_cfg_train_file /raid/simrdwn/configs/faster_rcnn_resnet101_simrdwn.config --train_tf_record /raid/simrdwn/data/labels_airplane_boat_car_train.tfrecord --max_batches 30000 --batch_size 16 --gpu 0

Permit me to introduce myself...
Well, I’m glad we got that out of the way.

Traceback (most recent call last):
  File "/raid/simrdwn/core/simrdwn.py", line 1955, in <module>
    main()
  File "/raid/simrdwn/core/simrdwn.py", line 1946, in main
    args = update_args(args)
  File "/raid/simrdwn/core/simrdwn.py", line 114, in update_args
    args.yolt_object_labels_str = ','.join(args.yolt_object_labels)
TypeError: sequence item 0: expected string, int found

Are the x,y,width,height absolute values?

What are the type of annotations SIMRDWN expects with regards to the bounding box coordinates. I understand the model expects <x>,<y>,<width>,<height> where x,y is the coordinate of the center of the rectangle. So my question is does SIMRDWN expect absolute valued bbox coordinates i.e. pixel values range from (0 to 1] or does it require bbox coordinates w.r.t to the image size?

question about the preparing of the data

Hey,avanetten
Thanks for you updating of the 'parse_cowc.py', and sorry for troubling you again. I have run the updated 'parse_cowc.py' again,and got the training list. But I have some questiones about the training list,which generated by the code.
Firstly, in the list of my data,since I put the xxx.png and the xxx_Annotated_Cars.png and the xxx_Annotated.xcf together,so the list contains all the files. Does the list need the xxx_Annotated_Cars.png and the xxx_Annotated.xcf in the following data transformed steps?
Sencodly, in the code 'preprocess_tfrecords.py', I found the code , 'label_file_full = image_file_full.split('.')[0].replace('images', 'labels') + '.txt'', we have generated the training list in the 'parse_cowc.py', but haven't generated the label.txt. I think the label.txt is necessary, but how can we generate the label.txt ? and what the use of .csv,which is generated by the 'parse_cowc.py'?
I am very interested in your work, and looking forward to your reply
Thank you for your great work again

Testing Bug: text file of class does not exist

During the testing phase, the program halts due to the absence of a file named building.txt which is the text file containing detections of my class (building). However, it doesn't appear to have been generated during testing phase and I'm unsure as to why.

Loading weights from /raid/local/src/simrdwn/results/train_yolt_dense_buildings_2019_01_16_07-05-19/ave_dense_20000_tmp.weights...label i: 0, tmp0
label i: 1, building
Done!
Learning Rate: 0.0001, Momentum: 0.9, Decay: 0.0005
valid_list_loc: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/valid_splitims_input_files.txt
Output file: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/tmp0.txt

Total Detection Time: 22.91982 Seconds
Length of time to run command:  ./yolt/darknet -i 0 yolt2 valid /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/logs/ave_dense.cfg /raid/local/src/simrdwn/results/train_yolt_dense_buildings_2019_01_16_07-05-19/ave_dense_20000_tmp.weights null 0 0.0 null /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09 /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/valid_splitims_input_files.txt tmp0,building 2 3 /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/logs/yolt_loss.txt 0.15  2>&1 | tee -a /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/logs/valid_yolt_dense_buildings_2019_01_17_13-31-09.log for 0 cutouts: 25.2416059971 seconds
"
valid_file: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/tmp0.txt
Augmenting dataframe of initial length: 2 ...
removing bad idxs: [0, 1]
Time to augment dataframe of length: 0 = 0.0165009498596 seconds
valid_file: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/building.txt
Traceback (most recent call last):
  File "simrdwn/core/simrdwn.py", line 1953, in <module>
    main()
  File "simrdwn/core/simrdwn.py", line 1945, in main
    execute(args)
  File "simrdwn/core/simrdwn.py", line 1475, in execute
    rotate_boxes=args.rotate_boxes)
  File "simrdwn/core/simrdwn.py", line 1022, in run_valid
    rotate_boxes=rotate_boxes)
  File "/raid/local/src/simrdwn/core/post_process.py", line 291, in post_process_yolt_valid_create_df
    'Ymax'])
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 678, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 440, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 787, in __init__
    self._make_engine(self.engine)
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 1014, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 1708, in __init__
    self._reader = parsers.TextReader(src, **kwds)
  File "pandas/_libs/parsers.pyx", line 384, in pandas._libs.parsers.TextReader.__cinit__
  File "pandas/_libs/parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source
IOError: File /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_17_13-31-09/building.txt does not exist

Do the x, y values in the YOLT format refer to cartesian x, y or row, col values?

I am not able to download any of the COWC dataset, the links are either dead or I do not receive a link to the FTP server for Toronto, Vaihingen and Potsdam. But I do have some of my own images that I want to experiment with.

I just wanted to ask if the YOLT file format expects the x and y coordinates to be in the cartesian frame (i.e. (0,0) is at the bottom left) or in a row, col system (i.e. (0,0) is at the top left)?

Also, is it true that the x, y, width and height values are expressed as a proportion of the image (i.e. the centroid of an object at the centre of a 100px * 100px image should be expressed as (x, y) = (0.5, 0.5)?

Thanks

install error of the Updated SIMRDWN?

I installed previously before 2 months, it was fine. but when again try to make updated yolt2 and yolt3, it gives the following error:
obj/gemm.o: file not recognized: File format not recognized collect2: error: ld returned 1 exit status Makefile:65: recipe for target 'darknet' failed make: *** [darknet] Error 1
Would you give suggestion please, Thanks

question about the Create YOLT Format

Hi, avanetten
Thanks for your great work!
I have some questions about the Create YOLT Format. Firstly,I have run the 'parse_cowc.py' successfuly,and got the '_truth_df.csv' file But I could not get the 'training_list.txt' ,which you said in the README.md. I have read the code of the script,'parse_cowc.py',and could not find the command to create a txt file,could you tell me how to create the txt file and what the format of the txt file is?
Except for your replying! Thank you so much!

Evaluation Result not displayed

I used the following command to test the trained model on two test images.
python simrdwn/core/simrdwn.py --framework yolt --mode valid --outname dense_buildings --yolt_object_labels_str building --train_model_path train_yolt_dense_buildings_2019_01_16_07-05-19 --weight_file ave_dense_20000_tmp.weights --yolt_cfg_file ave_dense.cfg --valid_testims_dir test_images2 --use_tfrecords 0 --min_retain_prob=0.15 --keep_valid_slices 0 --slice_overlap 0.1 --slice_sizes_str 544 --valid_slice_sep __ --plot_thresh_str 0.2 --valid_make_legend_and_title 0 --edge_buffer_valid 1 --valid_box_rescale_frac 1 --alpha_scaling 1 --show_labels 0

The model successfully slices the images and does inference but I can't find the resulting image with the predictions as sees in the README. The only image file I have is one called '00_colormap_legend.png' which looks like as follows:
img

Could anyone tell me why the image with the predictions made by the model wasn't generated?

Edit: Terminal output

1999 / 2000 
validate id: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/Satellite_AUH_split/Satellite_AUH__6846_0_544_544_0_17967_13205.png
2000 / 2000 
validate id: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/Satellite_AUH_split/Satellite_AUH__6846_2445_544_544_0_17967_13205.png
Total Detection Time: 57.93788 Seconds
"
Length of time to run command:  ./yolt/darknet -i 0 yolt2 valid /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/logs/ave_dense.cfg /raid/local/src/simrdwn/results/train_yolt_dense_buildings_2019_01_16_07-05-19/ave_dense_20000_tmp.weights null 0 0.0 null /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46 /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/valid_splitims_input_files.txt building 1 3 /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/logs/yolt_loss.txt 0.15  2>&1 | tee -a /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/logs/valid_yolt_dense_buildings_2019_01_27_09-31-46.log for 0 cutouts: 60.2704069614 seconds
"
valid_file: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/building.txt
Augmenting dataframe of initial length: 69 ...
removing bad idxs: [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 42, 43, 44, 45, 46, 49, 50, 51, 52, 53, 54, 55, 56, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68]
Time to augment dataframe of length: 7 = 0.0232398509979 seconds
"Length of time to run valid for 6 files = 94.0050060749 seconds
"
validation data sliced? True
Plotting at: 0.2
Running refine_df()...
Inintial length: 7 Final length: 0
Time to run refine_df(): 0.00775718688965 seconds
Running plot_refined_df...
Time to run plot_refined_df(): 0.0173439979553 seconds
"Length of time to run refine_valid() 0.0269501209259 seconds
"
Removing valid_split_dir_tmp: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/Davis_Monthan_AFB_20180814_split/
Removing image chips...
Removing valid_split_dir_tmp: /raid/local/src/simrdwn/results/valid_yolt_dense_buildings_2019_01_27_09-31-46/Satellite_AUH_split/
Removing image chips...
"Length of time to run valid 94.1890370846 seconds
"

No honeymoon. This is business.

What's the format of the training_images_list and how can I generate it?

I have tiled jpg images and the corresponding annotations. How can I generate the training_list.txt? As I understand it is a list of the images and their locations. So is it of the format

Name Location

img1.jpg path/to/img1
img2.jpg path/to/img2

If this is indeed the format, I could manually generate it.

Running on gpu within docker

I copied over the simrdwn folder into the docker container and set it up as per the instructions provided. However, I've noticed that running the following train command in the docker container does not use the gpu, and as such each iteration takes about an hour to complete.

# YOLT vehicle search
python /simrdwn/core/simrdwn.py \
	--framework yolt \
	--mode train \
	--outname dense_3class_vehicles \
	--yolt_object_labels_str tmp0,airplane,boat,car \
	--yolt_cfg_file ave_dense.cfg  \
	--weight_dir /simrdwn/yolt/input_weights \
	--weight_file yolo.weights \
	--yolt_train_images_list_file labels_airplane_boat_car_list.txt \
	--label_map_path /simrdwn/data/class_labels_airplane_boat_car.pbtxt \
	--nbands 3 \
	--max_batches 30000 \
	--batch_size 64 \
	--subdivisions 16 \
	--gpu 0

How can I run the program within the container using a gpu?

Pretrained weights?

Are there any pretrained weights available somewhere? If not, that might be of value, and of greater value if you add those to the docker image, so people can use it right away.

Create my own training data

I have some questions about training data.
I have satellite imagery which is tif format. And in 1A Create YOLT format said 'training data needs to be transformed to the YOLO format'. I know the YOLO format (also faster rcnn) is .jpg images and .xml labels. But how I transform my tif satellite imagery into jpg image?
The tif satellite imagery is 48 bit depth, but my transformed jpg image is 24 bit depth which is blur.
Thanks a lot !

Running inference in satellite imagery with model trained in Tensorflow object detection API

Dear Avanetten,

First of all, cheers for such an amazing work. I have trained my model directly in Tensorflow Object Detection API, without using SIMRDWN.
Can i use that frozen inference graph, and clone this SIMRDWN repository to run inference in very high resolution digital globe imagery or i need to explicitly train my model in SIMRDWN to run inference ?

Thank you. I look forward to hear from you.

Best Regards,

Suman

Limitation about the number of test images?

@avanetten Sorry for opening such type of issue.
I am facing a new problem with simrdwn for testing. I have 100 images in the test_images folder, but it always detect only 10 images.

Would you tell me please why it is happening?

When training: ModuleNotFoundError: No module named 'object_detection'

I am using the SpaceNet Khartoum building training dataset. After wrangling all the data together I believe that I am ready to begin training, but I immediately ran into this error:

(simrdwn2) root@769ca72c93be:/# Traceback (most recent call last):
  File "/tensorflow/models/research/object_detection/model_main.py", line 25, in <module>
    from object_detection import model_hparams
ModuleNotFoundError: No module named 'object_detection

I was wondering if perhaps this is an indicator of having missed a crucial step early on. The command that I ran was as follows:

python /simrdwn/simrdwn/core/simrdwn.py \
	--framework ssd \
	--mode train \
	--outname kartoum_buildings \
	--label_map_path /simrdwn_data/pbtext/buildings.pbtxt \
	--tf_cfg_train_file /simrdwn/tf/cfg/_altered_v0/ssd_inception_v2_simrdwn.config \
	--train_tf_record /simrdwn_data/tfrecord/labels_building_train.tfrecord \
	--max_batches 30000 \
	--batch_size 16 

(I mounted a second directory called simrdwn_data to the container as I wanted to keep my data directly separate from the original repo directory).

The full output can be found here. I put it on a pastebin so as not to clog up this page.

It seems as though it may be related to this issue on the tensorflow repo. But the suggested fixes appear to already be present in this repo's (SIMRDWN's) dockerfile.

Training not starting on latest code

The code gets stuck over here:

_Loading weights from /home/raj/Desktop/codes/simrdwn/yolt/input_weights/yolov2.weights...label i: 0, airplane

Done!
Learning Rate: 0.0001, Momentum: 0.9, Decay: 0.0005

Num images = 64,
i= 0
N ims: 1
Num iters: 30000_

After which, nothing happens

NaNs during training with own data, Yolt

First of all, thanks for this repository.
It's great to see an attempt at solving the problem of detecting arbitrarily small objects.

When training with my own data, I get NaN values during (what I assume is) the evaluation phase:

Batch Num: 66 / 100
66: 0.004850, 0.246441 avg, 0.000100 rate, 4.912205 seconds, 4224 images
Loaded: 0.000161 seconds
Batch Num: 67 / 100
Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.496874, Avg Recall: -nan,  count: 0
Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.496873, Avg Recall: -nan,  count: 0
Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.496883, Avg Recall: -nan,  count: 0

My setup is as follows:

  • Data: A single picture of solar panels. The image is 800x800. All panels are annotated. This file is stored at /raid/data/images/pic_1.jpg
  • A label_map.pbtxt file
item {
  id: 0
  name: 'panel'
}
  • At /raid/data/labels/pic_1.txt, A single labels file for the image
    with a class_id <x_center> <y_center> <width> <height> layout
0,0.8359,0.9758980657046362,0.0114,0.027325759901750075
0,0.8356,0.9481117592876881,0.0116,0.0276327909118821
...
  • An image_names.txt file with the following content
/raid/data/images/pic_1.jpg

The training process is instantiated with this command

/raid/simrdwn/core/simrdwn.py     
    --framework yolt     
    --mode train     
    --outname panel_detector
    --yolt_object_labels_str panel
    --yolt_cfg_file yolt.cfg
    --weight_dir /simrdwn/yolt/input_weights
    --weight_file yolov2.weights    
    --yolt_train_images_list_file /raid/data/image_names.txt
    --label_map_path /raid/data/label_map.pbtxt 
    --max_batches 100     
    --batch_size 64
    --subdivisions 16
    --gpu 0

What am I doing wrong?

No detection during test time

I was trying to reproduce the result with COWC, however, there are no cars detected during test time while the loss curve during training time looks reasonable:

yolt_loss_plot_tiny_cowc

I was using yolo-v2-tiny config and weights, and I was using Tesla K80 on GCP with CUDA Version: 10.1. Any idea on what's going wrong??

Amount of data for training

How much data is required in general for training?
Also, if possible, can you share the pretrained weights file?

Nan problems during training

I'm having a possible gradient issue while training. When training on batches the following prompt comes up:

Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.463884, Avg Recall: -nan, count: 0
Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.463872, Avg Recall: -nan, count: 0
Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.463883, Avg Recall: -nan, count: 0
....

Does anyone how to rectify it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.