# How to classify the images in the dataset from roboflow

**URL:** <https://discuss.roboflow.com/t/how-to-classify-the-images-in-the-dataset-from-roboflow/4476>\
**Category:** 🤝  Community Help\
**Created:** [February 14, 2024, 12:03am UTC](https://discuss.roboflow.com/t/how-to-classify-the-images-in-the-dataset-from-roboflow/4476 "2024-02-14T00:03:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jensontmathew](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jensontmathew](https://discuss.roboflow.com/u/jensontmathew)\
**Post date:** [February 14, 2024, 12:03am UTC](https://discuss.roboflow.com/t/how-to-classify-the-images-in-the-dataset-from-roboflow/4476/1 "2024-02-14T00:03:05Z")

</div>

I want to use the dataset from roboflow for one of my projects. I downloaded the dataset but the files are not grouped based on the classes. How can I classify the images based on classes.

- **object detection**
- **Windows 11 Home & firefox**
- **[Project Universe Link or Workspace/Project ID:](https://universe.roboflow.com/university-g3h71/swimming-and-drowning-detection)**

---

<div class="post-metadata">

**Author:** ![Lenny](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/lenny/32/2383_2.png) [@Lenny](https://discuss.roboflow.com/u/Lenny)\
**Post date:** [February 14, 2024, 12:04am UTC](https://discuss.roboflow.com/t/how-to-classify-the-images-in-the-dataset-from-roboflow/4476/2 "2024-02-14T00:04:06Z")

</div>

If your images are not grouped by class, you can label them in Roboflow. Here’s how you can do it:

1. Add your images to Roboflow.
2. Assign a user in your account to label them. This could be you or someone else in your team.
3. Labeling single-label classification data can be quick if you only have a few classes of data. If you have a large dataset, consider labeling 50 to 100 images, then using Roboflow Train to enable model assisted labeling. Model assisted labeling can help speed up labeling time by automatically applying best estimate labels to your images.

Here’s an example of how you can download a dataset from Roboflow:

```python
from roboflow import Roboflow

rf = Roboflow.login()

project = rf.workspace("popular-benchmarks").project("mit-indoor-scene-recognition")
dataset = project.version(5).download("folder")

```

After downloading, you can create a dictionary that maps all of the file names to the name of the folder they are in so that you know the label for each image:

```python
import os

cwd = os.getcwd()

ROOT_DIR = os.path.join(cwd, "MIT-Indoor-Scene-Recognition-5/train")

labels = {}

for folder in os.listdir(ROOT_DIR):
    for file in os.listdir(os.path.join(ROOT_DIR, folder)):
        if file.endswith(".jpg"):
            full_name = os.path.join(ROOT_DIR, folder, file)
            labels[full_name] = folder

files = labels.keys()

```

This way, you can classify your images based on classes.

Sources:

- [How to Classify Images with DINOv2](https://blog.roboflow.com/how-to-classify-images-with-dinov2#step-2-load-mit-scene-recognition-dataset)
- [How to Train YOLOv5-Classification on a Custom Dataset](https://blog.roboflow.com/train-yolov5-classification-custom-data#prepare-a-custom-dataset-for-classification)

* * *

> Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, and forum. If this solves your issue, please mark it as the solution using the checkbox icon. **If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.**

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)\
**Post date:** [March 6, 2024, 12:04am UTC](https://discuss.roboflow.com/t/how-to-classify-the-images-in-the-dataset-from-roboflow/4476/3 "2024-03-06T00:04:57Z")

</div>

Closed on March 6, 2024, 12:04am UTC

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
