question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to train Custom Dataset

See original GitHub issue

This guide explains how to train your own custom dataset with fastreid’s data loaders.

Before You Start

Following Getting Started to setup the environment and install requirements.txt dependencies.

Train on Custom Dataset

  1. Register your dataset (i.e., tell fastreid how to obtain your dataset).

    To let fastreid know how to obtain a dataset named “my_dataset”, users need to implement a Class that inherits fastreid.data.datasets.bases.ImageDataset:

    from fastreid.data.datasets import DATASET_REGISTRY
    from fastreid.data.datasets.bases import ImageDataset
    
    
    @DATASET_REGISTRY.register()
    class MyOwnDataset(ImageDataset):
    	def __init__(self, root='datasets', **kwargs):
    		...
    		super().__init__(train, query, gallery)		
    

    Here, the snippet associates a dataset named “MyOwnDataset” with a class that processes train set, query set and gallery set and then pass to the baseClass. Then add a decorator to this class for registration.

    The class can do arbitrary things and should generate train list: list(str, str, str), query list: list(str, int, int) and gallery list: list(str, int, int) as below.

    train_list = [
    (train_path1, pid1, camid1), (train_path2, pid2, camid2), ...]
    
    query_list = [
    (query_path1, pid1, camid1), (query_path2, pid2, camid2), ...]
    
    gallery_list = [
    (gallery_path1, pid1, camid1), (gallery_path2, pid2, camid2), ...]
    

    You can also pass an empty train_list to generate a “Testset” only with super().__init__([], query, gallery).

    Notice: query and gallery sets could have the same camera views, but for each individual query identity, his/her gallery samples from the same camera are excluded. So if your dataset has no camera annotations, you can set all query identities camera number to 0 and all gallery identities camera number to 1, then you can get the testing results.

  2. Import your dataset.

    Aftre registering your own dataset, you need to import it in train_net.py to make it effective.

    from dataset_file import MyOwnDataset
    

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
L1aoXingyucommented, Sep 22, 2020

@AnhPC03 Yes, you are right! It doesn’t matter how your data structure is. The key idea is preparing the train, query and gallery as required and then pass via super().__init__(train, query, gallery).

0reactions
github-actions[bot]commented, Dec 4, 2021

This issue was closed because it has been inactive for 14 days since being marked as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Train YOLO v5 on a Custom Dataset - Paperspace Blog
Set up the Code · Download the Data · Convert the Annotations into the YOLO v5 Format. YOLO v5 Annotation Format; Testing the...
Read more >
Training YOLOv5 custom dataset with ease - Medium
Step 1 — clone and install YOLOv5 and its dependencies · Step 2 — Getting & preparing the data · Step 3 —...
Read more >
How to Train A Custom Object Detection Model with YOLO v5
In this post, we will walk through how you can train the new YOLO v5 model to recognize your ... Download a custom...
Read more >
How to Train YOLOv7 on a Custom Dataset - Roboflow Blog
Training the Yolov7 with Custom Data. After pasting the dataset download snippet into your YOLOv7 Colab notebook, you are ready to begin the ......
Read more >
Custom training: walkthrough | TensorFlow Core
Training loop · Iterate each epoch. · Within an epoch, iterate over each example in the training Dataset grabbing its features ( x...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found