timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
5.15k stars 644 forks source link

Error in running other DL models for Image Classification #446

Closed sarwanpasha closed 2 years ago

sarwanpasha commented 2 years ago

How to use other DL models for image classification? On TS-to-ImageClassification tutorial (https://github.com/timeseriesAI/tsai/blob/main/tutorial_nbs/06_TS_to_image_classification.ipynb), xresnet34 model is used.

However, If I use some other models such as "OmniScaleCNN" (from https://github.com/timeseriesAI/tsai/blob/main/tutorial_nbs/05_TS_archs_comparison.ipynb), I get different errors. No model other than "xresnet34" works for image classification.

Can you tell me how to apply other models for image classification tutorial give on this link https://github.com/timeseriesAI/tsai/blob/main/tutorial_nbs/06_TS_to_image_classification.ipynb

oguiza commented 2 years ago

Hi @sarwanpasha, The reason why you see this error is because you're trying to use a time series model with images. Input to time series model is [batch size x channels x sequence length] while input to vision models is [batch sizes x channels (3) x height x width]. When you are using ts to image transforms you may use any Pytorch vision model. The only ones included by default in tsai are all from the xresnet family of models.

sarwanpasha commented 2 years ago

Can you tell me how can I save the images (along with their corresponding labels) that are the result of the transformation of time series to images to the memory so that I can use other pytorch vision models on them?

oguiza commented 2 years ago

There's no specific method to save images and labels in tsai. The intent is to create the "images" on the fly. However, if you wanted to save them, you could build a dataloader with the desired batch_transforms, shuffle=False, and drop_last=False, and iterate it saving the generated batches. Bear in mind that these are not real images. What I mean is that the number of channels may not necessarily be 3. That means you'll need to use a vision model that takes a variable for the number of input channels.

oguiza commented 2 years ago

I’ll close this issue due to a lack of a response. Please, reopen if necessary.