Malhar Khairnar
Malhar Khairnar

Reputation: 1

How to handle dataset which is a csv file that contains image names in one column and image path in other column?

I am new to python and machine learning. I am just practicing with model training and dataset thingy. I came across this dataset that have test and train folder. In that folder there are several containing different images (It's a music instrument dataset so each music instrument is categorized by names in different folders). And the csv file has this name of the instrument and their path in the folder like this: Instrument.csv

Now my question is how do I handle this dataset? Should I iterate through train and test folders or use this csv file? And if I want to choose the folder option then how can go through each sub-folder and access the images? Here is the link for the dataset : https://www.kaggle.com/datasets/gpiosenka/musical-instruments-image-classification

sorry if the question doesn't make any sense or too easy to do it. I agree I am noob

Upvotes: 0

Views: 700

Answers (2)

sudhanshu480
sudhanshu480

Reputation: 1

You can first download the data and then extract cnn features to train your model.

You can download data using this code: Considering the link of images is in the column named 'images_link'

import pandas as pd
train_df = pd.read_csv("dataset/train.csv")
download_image(train_df['image_link'], 'images')

Upvotes: 0

Kanagaryu
Kanagaryu

Reputation: 86

You should read the csv file into a pandas dataframe to create your dataset. Alternatively, you can also iterate through the directories using os.listdir() https://docs.python.org/3/library/os.html

Upvotes: 0

Related Questions