Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
avanetten authored and avanetten committed May 23, 2018
0 parents commit b1d0063
Show file tree
Hide file tree
Showing 1,064 changed files with 53,329 additions and 0 deletions.
85 changes: 85 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
GPU=1
CUDNN=1
OPENCV=1
DEBUG=0

# with cudnn6, need to update convolutional_layer.c:
# https://groups.google.com/forum/#!topic/darknet/AEP4qwIPwa4

ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=[sm_50,compute_50] \
-gencode arch=compute_52,code=[sm_52,compute_52] \
-gencode arch=compute_61,code=[sm_61,compute_61]

VPATH=./src/
EXEC=darknet
OBJDIR=./obj/

CC=gcc
NVCC=nvcc
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON=-I/Users/avanetten/anaconda/pkgs/libgdal-2.1.0-0/include
CFLAGS=-Wall -Wfatal-errors

ifeq ($(DEBUG), 1)
OPTS=-O0 -g
endif

CFLAGS+=$(OPTS)

ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv`
COMMON+= `pkg-config --cflags opencv`
endif

ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif

ifeq ($(CUDNN), 1)
COMMON+= -DCUDNN
CFLAGS+= -DCUDNN
LDFLAGS+= -lcudnn
endif

OBJ=gemm.o utils.o cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o yolt.o yolt2.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o super.o voxel.o tree.o
ifeq ($(GPU), 1)
LDFLAGS+= -lstdc++
OBJ+=convolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o network_kernels.o avgpool_layer_kernels.o
endif

OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard src/*.h) Makefile

all: obj results $(EXEC)
#all: obj backup results $(EXEC)


$(EXEC): $(OBJS)
$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)

$(OBJDIR)%.o: %.c $(DEPS)
$(CC) $(COMMON) $(CFLAGS) -c $< -o $@

$(OBJDIR)%.o: %.cu $(DEPS)
$(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@

obj:
mkdir -p obj
#backup:
# mkdir -p backup
results:
mkdir -p results

.PHONY: clean

clean:
rm -rf $(OBJS) $(EXEC)

103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# YOLT #

# You Only Look Twice: Rapid Multi-Scale Object Detection In Satellite Imagery

YOLT is an extension of the YOLO framework (https://pjreddie.com/darknet/yolov2/) that can evaluation satellite images of arbitrary size, and runs at ~50 frames per second.

References:

arxiv

https://medium.com/the-downlinq/you-only-look-twice-multi-scale-object-detection-in-satellite-imagery-with-convolutional-neural-38dad1cf7571

https://medium.com/the-downlinq/you-only-look-twice-multi-scale-object-detection-in-satellite-imagery-with-convolutional-neural-34f72f659588

https://medium.com/the-downlinq/building-extraction-with-yolt2-and-spacenet-data-a926f9ffac4f

https://medium.com/the-downlinq/car-localization-and-counting-with-overhead-imagery-an-interactive-exploration-9d5a029a596b

https://medium.com/the-downlinq/the-satellite-utility-manifold-object-detection-accuracy-as-a-function-of-image-resolution-ebb982310e8c

https://medium.com/the-downlinq/panchromatic-to-multispectral-object-detection-performance-as-a-function-of-imaging-bands-51ecaaa3dc56

If you plan on using YOLT in your work, please consider citing YOLO (https://arxiv.org/abs/1612.08242) and YOLT (arxiv)



The YOLT code alters a number of the files in src/*.c to allow further functionality. We also build a python wrapper around the C functions to improve flexibility. We utililize the default data format of YOLO, which places images and labels in different forlders.
An example training data and image:

/data/images/train1.tif
/data/labels/train1.txt
Each line of the .txt file has the format

<object-class> <x> <y> <width> <height>
Where x, y, width, and height are relative to the image's width and height.

Labels can be created with https://github.com/tzutalin/labelImg, and converted to the appropriate format with the /yolt/scripts/convert.py script. Also see https://github.com/Guanghan/darknet for an example of YOLO modifications.


# Execution #

##############################################
# HELP
python yolt2.py --help

##############################################
# COMPILE (gpu machine)
python yolt2.py \
--mode compile


##############################################
# TRAIN (gpu_machine)


# Boats and planes
python ../scripts/yolt2.py \
--mode train \
--outname 3class_boat_plane \
--object_labels_str boat,boat_harbor,airplane \
--cfg_file ave_13x13.cfg \
--nbands 3 \
--weight_file ave_13x13_boats_planes_voc.weights \
--train_images_list_file boat_airplane_all.txt \
--single_gpu_machine 0 \
--keep_valid_slices False \
--max_batches 60000 \
--gpu 1

##############################################
# VALIDATE (gpu_machine)

# test on all: boats, cars, and airplanes with new model
cd /raid/local/src/yolt2/results/
python ../scripts/yolt2.py \
--mode valid \
--outname qgis_labels_all_boats_planes_cars_buffer \
--object_labels_str airplane,airport,boat,boat_harbor,car \
--cfg_file ave_26x26.cfg \
--valid_weight_dir train_cowc_cars_qgis_boats_planes_cfg=ave_26x26_2017_11_28_23-11-36 \
--weight_file ave_26x26_30000_tmp.weights \
--valid_testims_dir qgis_validation/all \
--keep_valid_slices False \
--valid_make_pngs True \
--valid_make_legend_and_title False \
--edge_buffer_valid 1 \
--valid_box_rescale_frac 1 \
--plot_thresh_str 0.4 \
--slice_sizes_str 416 \
--slice_overlap 0.2 \
--gpu 2


##############################################

TBD:

Upload data preparation scripts
Describe multispectral data handling
Describle initial results with YOLOv3
Describle better labeling methods

95 changes: 95 additions & 0 deletions cfg/alexnet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[net]
batch=128
subdivisions=1
height=227
width=227
channels=3
momentum=0.9
decay=0.0005
max_crop=256

learning_rate=0.01
policy=poly
power=4
max_batches=800000

angle=7
hue = .1
saturation=.75
exposure=.75
aspect=.75

[convolutional]
filters=96
size=11
stride=4
pad=0
activation=relu

[maxpool]
size=3
stride=2
padding=0

[convolutional]
filters=256
size=5
stride=1
pad=1
activation=relu

[maxpool]
size=3
stride=2
padding=0

[convolutional]
filters=384
size=3
stride=1
pad=1
activation=relu

[convolutional]
filters=384
size=3
stride=1
pad=1
activation=relu

[convolutional]
filters=256
size=3
stride=1
pad=1
activation=relu

[maxpool]
size=3
stride=2
padding=0

[connected]
output=4096
activation=relu

[dropout]
probability=.5

[connected]
output=4096
activation=relu

[dropout]
probability=.5

[connected]
output=1000
activation=linear

[softmax]
groups=1

[cost]
type=sse

Loading

0 comments on commit b1d0063

Please sign in to comment.