Code Monkey home page Code Monkey logo

baseline's Introduction

fMoW: Functional Map of the World

This code was developed by JHU/APL.

References

If you use our dataset or code, please cite our paper:

@inproceedings{fmow2018,
  title={Functional Map of the World},
  author={Christie, Gordon and Fendley, Neil and Wilson, James and Mukherjee, Ryan},
  booktitle={CVPR},
  year={2018}
}

Dependencies

The following libraries were used for training/testing the deep learning models:

Keras 2.0.8

Tensorflow 1.3.0

DenseNet from titu1994/DenseNet

Dataset

The following directory structure was used for training/testing:


fmow_dataset/
    train/
        airport/
            airport_0/
                airport_0_0_rgb.jpg
                airport_0_0_rgb.json
                ...
                airport_0_5_rgb.jpg
                airport_0_5_rgb.json
            ...
        ...
        
        zoo/
            zoo_0/
                zoo_0_0_rgb.jpg
                zoo_0_0_rgb.json
                ...
                zoo_0_8_rgb.jpg
                zoo_0_8_rgb.json
                
                ...

    test/
        0000000/
            0000000_0_rgb.jpg
            0000000_0_rgb.json
            ...
            0000000_5_rgb.jpg
            0000000_5_rgb.json
        ...

Results Format

This code will output txt files in the format required by Topcoder, where each line contains comma-separated values of the bounding box ID and a string containing the category. The txt files are stored in:

data/output

Running the Code

To first prepare the dataset for training and testing, change the following line in params.py to point to the RGB-only version of the dataset:

directories['dataset'] = '../../fmow_dataset'

Our code does not currently operate on the full (TIFF) version of the fMoW dataset, but this should be possible with simple code changes.

To process the dataset, saving the AOIs and saving metadata feature vectors, run the following code (note: this may take hours and will generate files occupying ~8.7GB):

python runBaseline.py -prepare

Once this is complete, the following arguments can be passed in to run different parts of the code:

-all: run everything
-cnn: train the CNN (default: with metadata -- use -nm to use only image features)
-codes: generate and save feature vectors to be passed to an LSTM
-lstm: train the LSTM using the codes generated by the CNN and concatenate metadata features (unless -nm argument used)
-test: generate predictions files using both CNN and LSTM models
-test_cnn: generate a predictions file only using the CNN
-test_lstm: generate a predictions file only using the LSTM
-nm: do not use metadata for training or testing

Pre-trained Models

Pre-trained models can be found under Releases: https://github.com/fMoW/baseline/releases

License

The license is Apache 2.0. See LICENSE.

baseline's People

Contributors

gordonac avatar lininglouis avatar mukhery 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

Watchers

 avatar  avatar  avatar  avatar  avatar

baseline's Issues

out of memory error

Hi guys,

when i run the code, i get the OOM error at :

model.fit_generator(train_datagen,
steps_per_epoch=(len(trainData) / self.params.batch_size_cnn + 1),
epochs=self.params.cnn_epochs, callbacks=callbacks_list)

It is running on Windows with Tensorflow backend. Even when i changed the batch_size to very small, it still has this problem.
Thanks.
the whole information like this:
OOM when allocating tensor with shape[32,14,14,1680]

 [[Node: concatenate_45/concat = ConcatV2[N=2, T=DT_FLOAT, Tidx=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](concatenate_44/concat, conv2d_93/convolution, concatenate_45/concat/axis)]]

 [[Node: metrics/acc/Mean/_10395 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_93784_metrics/acc/Mean", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op 'concatenate_45/concat', defined at:

File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_launcher.py", line 78, in

vspd.debug(filename, port_num, debug_id, debug_options, run_as)

File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_debugger.py", line 2483, in debug

exec_file(file, globals_obj)

File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_util.py", line 111, in exec_file

exec_code(code, file, global_variables)

File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_util.py", line 87, in exec_code

exec(code_obj, global_variables)

File "G:\programs\baseline-master\code\runBaseline.py", line 40, in

main("-prepare ")

File "G:\programs\baseline-master\code\runBaseline.py", line 29, in main

baseline.train_cnn()

File "G:\programs\baseline-master\code\fmowBaseline.py", line 93, in train_cnn

model = get_cnn_model(self.params)

File "G:\programs\baseline-master\code\data_ml_functions\mlFunctions.py", line 46, in get_cnn_model

baseModel = densenet.DenseNetImageNet161(input_shape=(params.target_img_size[0], params.target_img_size[1], params.num_channels), include_top=False, input_tensor=input_tensor)

File "G:\programs\baseline-master\code\data_ml_functions\DenseNet\densenet.py", line 446, in DenseNetImageNet161

classes=classes, activation=activation)

File "G:\programs\baseline-master\code\data_ml_functions\DenseNet\densenet.py", line 164, in DenseNet

dropout_rate, weight_decay, subsample_initial_block, activation)

File "G:\programs\baseline-master\code\data_ml_functions\DenseNet\densenet.py", line 639, in __create_dense_net

dropout_rate=dropout_rate, weight_decay=weight_decay)

File "G:\programs\baseline-master\code\data_ml_functions\DenseNet\densenet.py", line 502, in __dense_block

x = concatenate([x, cb], axis=concat_axis)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\keras\layers\merge.py", line 627, in concatenate

return Concatenate(axis=axis, **kwargs)(inputs)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\keras\engine\topology.py", line 603, in call

output = self.call(inputs, **kwargs)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\keras\layers\merge.py", line 347, in call

return K.concatenate(inputs, axis=self.axis)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 1778, in concatenate

return tf.concat([to_dense(x) for x in tensors], axis)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1066, in concat

name=name)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 493, in _concat_v2

name=name)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op

op_def=op_def)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op

original_op=self._default_original_op, op_def=op_def)

File "C:\Users\VS 02\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in init

self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[32,14,14,1680]

 [[Node: concatenate_45/concat = ConcatV2[N=2, T=DT_FLOAT, Tidx=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](concatenate_44/concat, conv2d_93/convolution, concatenate_45/concat/axis)]]

 [[Node: metrics/acc/Mean/_10395 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_93784_metrics/acc/Mean", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

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.