Giter Club home page Giter Club logo

tonic's Introduction

tonic PyPI codecov Documentation Status contributors Binder DOI Discord

Tonic is a tool to facilitate the download, manipulation and loading of event-based/spike-based data. It's like PyTorch Vision but for neuromorphic data!

Documentation

You can find the full documentation on Tonic on this site.

Install

pip install tonic

or (thanks to @Tobias-Fischer)

conda install -c conda-forge tonic

For the latest pre-release on the develop branch that passed the tests:

pip install tonic --pre

This package has been tested on:

Linux
Windows

Quickstart

If you're looking for a minimal example to run, this is it!

import tonic
import tonic.transforms as transforms

sensor_size = tonic.datasets.NMNIST.sensor_size
transform = transforms.Compose(
    [
        transforms.Denoise(filter_time=10000),
        transforms.ToFrame(sensor_size=sensor_size, time_window=3000),
    ]
)

testset = tonic.datasets.NMNIST(save_to="./data", train=False, transform=transform)

from torch.utils.data import DataLoader

testloader = DataLoader(
    testset,
    batch_size=10,
    collate_fn=tonic.collation.PadTensors(batch_first=True),
)

frames, targets = next(iter(testloader))

Discussion and questions

Have a question about how something works? Ideas for improvement? Feature request? Please get in touch on the #tonic Discord channel or alternatively here on GitHub via the Discussions page!

Contributing

Please check out the contributions page for details.

Sponsoring

The development of this library is supported by

SynSense

Citation

If you find this package helpful, please consider citing it:

@software{lenz_gregor_2021_5079802,
  author       = {Lenz, Gregor and
                  Chaney, Kenneth and
                  Shrestha, Sumit Bam and
                  Oubari, Omar and
                  Picaud, Serge and
                  Zarrella, Guido},
  title        = {Tonic: event-based datasets and transformations.},
  month        = jul,
  year         = 2021,
  note         = {{Documentation available under 
                   https://tonic.readthedocs.io}},
  publisher    = {Zenodo},
  version      = {0.4.0},
  doi          = {10.5281/zenodo.5079802},
  url          = {https://doi.org/10.5281/zenodo.5079802}
}

tonic's People

Contributors

anindyaghosh avatar antoinegrimaldi avatar bamsumit avatar biphasic avatar e-martinsson avatar fabrizio-ottati avatar gokulbnr avatar guidoz avatar jegp avatar jrfinkbeiner avatar k-chaney avatar kismde avatar laurentperrinet avatar marcorax avatar minakh avatar mrpeterjin avatar narduzzi avatar neworderofjamie avatar nkupelioglu avatar ooub avatar sheiksadique avatar tnowotny avatar tobias-fischer avatar twelshed avatar ugurcancakal avatar verilog-indeed avatar zuowenwang0000 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  avatar

tonic's Issues

When (some?) transform are applied, dataset __getitem__ returns tuple

If I add a transform:

subsample_transform = tonic.transforms.Subsample(1e-3)
dataset = tonic.datasets.SHD(save_to='./data', train=False, transform=subsample_transform)
events, label = dataset[0]

events is now a tuple with a superfluous None. This is really annoying so I'm more than happy to fix this in tonic rather than my code but, I'm not quite sure why transform classes are returning images at all (e.g. here) so not totally clear how to fix it. Would the correct fix be to duplicate this logic from transform.Compose across all transforms (the 'functional' transforms just seem to return events).

Introduce option to disable verification

At the moment the datasets are always verified, even if download=False. Hashing huge files takes quite a while though, and being able to skip the verification would be great.

Provide peer-to-peer links to increase download speed and resilience

Thanks for a great library! We're starting to rely on it quite a bit at my group.

I can see some datasets, such as the NMNIST, relies on a Dropbox link. This may make complete sense, but it may also be beneficial to use decentralized peer-to-peer services using, for instance, IPFS. That should make the datasets more resilient to link expiration, service outage, and download bandwidth.

This could also be coupled with #111 to decrease the download size and increase unpacking/processing speed.

Downloading Issue

I tried downloading the poker-dvs dataset and it works fine.However ,trying other datasets (Navgesture for example) ,download starts and after a while at about 27% it gives me an error: File not found or corrupted (its raised in the function check_integrity from download_utils.py) but the files do exist in the desired directory nor do I make any changes while the files are downloading. I am running this in a linux system (18.04) , I installed tonic with conda.

Dependency problem on readme example

First example under Readme has a dependency issue:

import tonic
import tonic.transforms as transforms

transform = transforms.Compose([transforms.Denoise(filter_time=10000),
                                transforms.TimeJitter(std=10),])

testset = tonic.datasets.NMNIST(save_to='./data',
                                train=False,
                                transform=transform)

testloader = tonic.datasets.DataLoader(testset, shuffle=True)

events, target = next(iter(testloader))

ModuleNotFoundError: No module named 'importRosbag.messageTypes'

tonic was installed via setup.py

NMNIST file integrity fails

After a successful download and extraction of the NMNIST dataset, the check_integrity check keeps failing for consecutive calls. Resulting in the zip file being extracted every time the dataset is being applied.

The expected behaviour would be to reuse the existing directory structure in the ./data/nmnist/ folder.

Create object interface

Create an object interface such that it is easy to compose a pipeline out of objects that store meaningful state.

Tonic transforms are not PyTorch Vision compatible

if we want to be able to chain torchvision transforms, we need to slightly change the way tonic transforms are instantiated. Currently we return events, images and sensor size from each one, but torchvision only works on a single piece of data (images). It would be good to bundle whatever a single sample of a tonic dataset returns into 1 tuple. That way, different transforms can be applied to each piece of data separately

Extend test events variation

test for many more variations including event arrays that are using dtypes, booleans for polarities, different orderings etc

Why float type for events?

I'm wondering why one would use a float type to return address-events, for example here:

return events.astype(float)

In neuromorphic sensors or hardware, addresses generally results from AER and are thus better encoded as unsigned integers

break out PyTorch dependencies

we currently include quite a large dependency for what we're using of it. Probably the most important functions we're relying on are pytorch visions download and verification utils https://github.com/pytorch/vision/blob/master/torchvision/datasets/utils.py
which could probably be copied and referenced, same goes for the VisionDataset class. Most transforms use numpy anyway, and for pytorch's sparse tensor transform we can just include it as an optional dependency.
This would help adoption by people who use other backends.

strict equality of floating point number in testFlipLr

self = <test_functional.TestFunctionalAPI testMethod=testFlipLR>

    def testFlipLR(self):
        original_x = self.random_xytp[0][0, 0].copy()
    
        events, images = F.flip_lr_numpy(
            self.random_xytp[0],
            images=self.random_xytp[1],
            sensor_size=self.random_xytp[2],
            ordering=self.random_xytp[3],
            multi_image=self.random_xytp[4],
            flip_probability=1.0,
        )
    
        print(self.random_xytp[2], self.random_xytp[0][0, 0])
        print(events[0, 0])
    
        self.assertEqual(
            self.random_xytp[2][0] - self.random_xytp[0][0, 0],
            original_x,
>           "When flipping left and right x must map to the opposite pixel, i.e. x' = sensor width - x",
        )
E       AssertionError: 31.38062971396687 != 31.380629713966858 : When flipping left and right x must map to the opposite pixel, i.e. x' = sensor width - x

test/numpy_test/test_functional.py:30: AssertionError

Should polarity be another sensor size dimension

i.e. SHD would have a sensor size of (700,) and a "tx" ordering to indicate it has no polarity and a DVS128 dataset would have a sensor size of (128,128,2) and a "xypt" ordering. Without this, the only way of knowing the actual number of input neurons is to check whether there are different polarities in the "p" row.

Sorry for making so many issues ๐Ÿ˜„

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.