Answer a question

I've looking for a solution to solve the slow upload speed of images dataset on google colab when i use a connection from GoogleDrive. Using the follow code:

from google.colab import drive

drive.mount('/content/gdrive')

Using this procedure i can upload images and create labels using a my def load_dataset:

'train_path=content/gdrive/MyDrive/Capstone/Enviroment/cell_images/train'

train_files, train_targets = load_dataset(train_path)

But, as i said, it's very slow, especially because my full dataset is composed by 27560 images.

To solve my problem, i've tried to use this solution.

But now, in order to still use my deffunction, after download the .tar file i wanna extract in a specific folder in the colab enviroment. I found this answer but not solve my problem.

Example:

This is the environment with the test.tar already downloaded. enter image description here

But i wanna extract the files in the tar file, which structure is train/Uninfected ; train/Parasitized, to get this:

  • content

    • cell_images
      • test
        • Parasitized
        • Uninfected
      • train
        • Parasitized
        • Uninfected
      • valid
        • Parasitized
        • Uninfected

To use the path in def function:

train_path = train_path=content/cell_images/train/'

train_files, train_targets = load_dataset(train_path)

test_path = train_path=content/cell_images/test/'

test_files, test_targets = load_dataset(test_path)

valid_path = train_path=content/cell_images/valid/'

valid_files, valid_targets = load_dataset(valid_path)

I tried to use: ! mkdir -p content/cell_images and !tar -xvf 'test.tar' content/cell_images

But it doesn't work.

Does anyone know how to proceed?

Thanks!

Answers

To extract the files from the tar archiver to the folder content/cell_images use the command-line option -C:

!tar -xvf  'test.tar' -C 'content/cell_images'

Hope this helps!

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐