admin管理员组文章数量:1026989
So i recently imported dataset from this website. And even though i have it in my files in google colab(unzipped and all that stuff), i dont know how to implement it in the code itself. Like from tutorial of Fashion mnist by tensorflow it loaded as
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
how do i import/load data to code cell and work with it by splitting into classes(because in that tutorial dataset has several classes and in my custom dataset it has 12) pls how to do it?
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# Define paths to your training and validation directories
train_dir = 'garbage-classification/train'
val_dir = 'garbage-classification/validation'
# Create an ImageDataGenerator for data augmentation
train_datagen = ImageDataGenerator(rescale=1./255)
val_datagen = ImageDataGenerator(rescale=1./255)
# Load images from directories
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(150, 150), # Resize images as needed
batch_size=32,
class_mode='categorical' # Use 'categorical' if you have multiple classes
)
validation_generator = val_datagen.flow_from_directory(
val_dir,
target_size=(150, 150),
batch_size=32,
class_mode='categorical'
)
i used perplexity to try to solve and it gave me this. It obviously didn't work so..
So i recently imported dataset from this https://www.kaggle/datasets/mostafaabla/garbage-classification website. And even though i have it in my files in google colab(unzipped and all that stuff), i dont know how to implement it in the code itself. Like from tutorial of Fashion mnist by tensorflow https://www.tensorflow./tutorials/keras/classification?hl it loaded as
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
how do i import/load data to code cell and work with it by splitting into classes(because in that tutorial dataset has several classes and in my custom dataset it has 12) pls how to do it?
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# Define paths to your training and validation directories
train_dir = 'garbage-classification/train'
val_dir = 'garbage-classification/validation'
# Create an ImageDataGenerator for data augmentation
train_datagen = ImageDataGenerator(rescale=1./255)
val_datagen = ImageDataGenerator(rescale=1./255)
# Load images from directories
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(150, 150), # Resize images as needed
batch_size=32,
class_mode='categorical' # Use 'categorical' if you have multiple classes
)
validation_generator = val_datagen.flow_from_directory(
val_dir,
target_size=(150, 150),
batch_size=32,
class_mode='categorical'
)
i used perplexity to try to solve and it gave me this. It obviously didn't work so..
Share Improve this question asked Nov 16, 2024 at 16:34 Uais AmangeldiUais Amangeldi 111 Answer
Reset to default 1The steps to download Kaggle datasets in Google Colab, including installing the Kaggle API, uploading the Kaggle API key, setting up authentication, downloading the dataset, unzipping the data (if necessary), and accessing the data.I have downloaded garbage_classification dataset and split it into training and validation are all executed in the following gist.
So i recently imported dataset from this website. And even though i have it in my files in google colab(unzipped and all that stuff), i dont know how to implement it in the code itself. Like from tutorial of Fashion mnist by tensorflow it loaded as
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
how do i import/load data to code cell and work with it by splitting into classes(because in that tutorial dataset has several classes and in my custom dataset it has 12) pls how to do it?
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# Define paths to your training and validation directories
train_dir = 'garbage-classification/train'
val_dir = 'garbage-classification/validation'
# Create an ImageDataGenerator for data augmentation
train_datagen = ImageDataGenerator(rescale=1./255)
val_datagen = ImageDataGenerator(rescale=1./255)
# Load images from directories
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(150, 150), # Resize images as needed
batch_size=32,
class_mode='categorical' # Use 'categorical' if you have multiple classes
)
validation_generator = val_datagen.flow_from_directory(
val_dir,
target_size=(150, 150),
batch_size=32,
class_mode='categorical'
)
i used perplexity to try to solve and it gave me this. It obviously didn't work so..
So i recently imported dataset from this https://www.kaggle/datasets/mostafaabla/garbage-classification website. And even though i have it in my files in google colab(unzipped and all that stuff), i dont know how to implement it in the code itself. Like from tutorial of Fashion mnist by tensorflow https://www.tensorflow./tutorials/keras/classification?hl it loaded as
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
how do i import/load data to code cell and work with it by splitting into classes(because in that tutorial dataset has several classes and in my custom dataset it has 12) pls how to do it?
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# Define paths to your training and validation directories
train_dir = 'garbage-classification/train'
val_dir = 'garbage-classification/validation'
# Create an ImageDataGenerator for data augmentation
train_datagen = ImageDataGenerator(rescale=1./255)
val_datagen = ImageDataGenerator(rescale=1./255)
# Load images from directories
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(150, 150), # Resize images as needed
batch_size=32,
class_mode='categorical' # Use 'categorical' if you have multiple classes
)
validation_generator = val_datagen.flow_from_directory(
val_dir,
target_size=(150, 150),
batch_size=32,
class_mode='categorical'
)
i used perplexity to try to solve and it gave me this. It obviously didn't work so..
Share Improve this question asked Nov 16, 2024 at 16:34 Uais AmangeldiUais Amangeldi 111 Answer
Reset to default 1The steps to download Kaggle datasets in Google Colab, including installing the Kaggle API, uploading the Kaggle API key, setting up authentication, downloading the dataset, unzipping the data (if necessary), and accessing the data.I have downloaded garbage_classification dataset and split it into training and validation are all executed in the following gist.
本文标签: pythonHow to use loaded data from kaggle in google colab( to actually work with it)Stack Overflow
版权声明:本文标题:python - How to use loaded data from kaggle in google colab( to actually work with it) - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745651778a2161361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论