Code Monkey home page Code Monkey logo

marlclassification's Introduction

MARLClassification

Multi-Agent Image Classification via Reinforcement Learning

TODO

  • train on AID
  • docstring

Results

Trained on MNIST (see resources/trained_models/mnist) :

Loss Train Eval
Epoch 0 1.5161 41%, 42% 44%, 44%
Epoch 20 0.5385 80%, 80% 80%, 79%
Epoch 39 0.5218 81%, 81% 82%, 81%

Train on image dataset NWPU-RESISC45 (see resources/trained_models/resisc45) :

Loss Train Eval
prec, rec prec, rec
Epoch 0 2.6236 21%, 26% 25%, 26%
Epoch 20 1.3262 57%, 57% 58%, 57%
Epoch 49 0.9263 68%, 68% 66%, 65%

Installation

$ cd /path/to/MARLClassification
$ # create and activate your virtual env
$ python -m venv venv
$ ./venv/bin/activate
$ # install requirements
$ pip install -r requirements.txt
$ # download datasets using sh scripts in resources folder, ex : MNIST
$ ./resources/download_mnist.sh

You may download datasets with bash scripts in res folder.

Usage

To run training :

$ cd /path/to/MARLClassification
$ # train on MNIST
$ python -m marl_classification -a 3 --step 5 --cuda --run-id train_mnist train --action [[1,0],[-1,0],[0,1],[0,-1]] --img-size 28 --nb-class 10 -d 2 --f 6 --ft-extr mnist --nb 64 --na 64 --nm 16 --nd 8 --nlb 96 --nla 96 --batch-size 32 --lr 1e-3 --nb-epoch 40 -o ./out/mnist_actor_critic
$ # train on NWPU-RESISC45
$ python -m marl_classification -a 16 --step 16 --cuda --run-id train_resisc45 train --action [[1,0],[-1,0],[0,1],[0,-1]] --ft-extr resisc45 --batch-size 8 --nb-class 45 --img-size 256 -d 2 --nb 256 --na 256 --nd 16 --f 12 --nm 64 --nlb 384 --nla 384 --nb-epoch 50 --lr 1e-4 -o ./out/resisc45_actor_critic
$ # train on AID
$ python -m marl_classification -a 16 --step 16 --cuda --run-id train_aid train --action [[3,0],[-3,0],[0,3],[0,-3]] --ft-extr aid --batch-size 8 --nb-class 30 --img-size 600 -d 2 --nb 256 --na 256 --nd 16 --f 24 --nm 64 --nlb 320 --nla 320 --nb-epoch 50 --lr 1e-4 -o ./out/aid_actor_critic

Reference

[1]: https://arxiv.org/abs/1905.04835, Hossein K. Mousavi, Mohammadreza Nazari, Martin Takáč, Nader Motee - 2019

marlclassification's People

Contributors

ipsedo 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

Watchers

 avatar  avatar  avatar

marlclassification's Issues

OSError: Could not find kaggle.json. Make sure it's located in /root/.kaggle. Or use the environment method.

While running download_minist.sh file I am facing the following error,
Download MNIST png from Kaggle
Traceback (most recent call last):
File "/opt/conda/bin/kaggle", line 5, in
from kaggle.cli import main
File "/opt/conda/lib/python3.7/site-packages/kaggle/init.py", line 23, in
api.authenticate()
File "/opt/conda/lib/python3.7/site-packages/kaggle/api/kaggle_api_extended.py", line 166, in authenticate
self.config_file, self.config_dir))
OSError: Could not find kaggle.json. Make sure it's located in /root/.kaggle. Or use the environment method.
Extract mnistzip.zip
unzip: cannot find or open /kaggle/working/MARLClassification/resources/downloaded/mnistzip.zip, /kaggle/working/MARLClassification/resources/downloaded/mnistzip.zip.zip or /kaggle/working/MARLClassification/resources/downloaded/mnistzip.zip.ZIP.
Create all_png folder
mkdir: cannot create directory ‘/kaggle/working/MARLClassification/resources/downloaded/mnist_png/all_png’: No such file or directory
Copy train img to all_png folder
cp: cannot stat '/kaggle/working/MARLClassification/resources/downloaded/mnist_png/train/': No such file or directory
Copy eval img to all_png folder
cp: cannot stat '/kaggle/working/MARLClassification/resources/downloaded/mnist_png/valid/
': No such file or directory

Getting Same Class ID During Inferencing

Hi,

Great work!

I have trained a new model with 2 class using the 0 and 1 class images from mnist and got a 90% precision and 90% Recall
but when i do inference on single image always getting predicted class id 0
confusion_matrix_epoch_39_eval
marl.json

animated_gif
animated_gif

predicted class and the confidence is coming same.

i have trained on custom data as well by increasing the number of agents and observations still same issue.

but at the end of the training the result looks different
animated_gif

Thanks

3D Image Volume Capability

Are there plans to adapt this code for 3D image volume data? I see that there is a default training argument for dim=2, but when I load a 3D grayscale image (shape = (40,320,320), and set dim = 3 and nb_actions=6, the code throws and error on the return of ./environment/observation.py.

Steps for Evaluation on test data and Inference on single input image.

Hi @Ipsedo,

I have gone through your code, and I am able to train the model on the custom dataset, but while doing the inference and evaluation, I am confused with the eval options and main options, state_dict.

it would be helpful if you provide the steps or documentation for doing inference on a single image and testing the model on test dataset.

Thanks in advance.

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.