How to Train a Computer Vision Model with Focoos#
Focoos provides a comprehensive training framework that makes it easy to train state-of-the-art computer vision models on your own datasets. Whether you're working on object detection, image classification, or other vision tasks, Focoos offers an intuitive training pipeline that handles everything from data preparation to model optimization.
Key features of the Focoos training framework include:
- Easy Dataset Integration: Seamlessly import and prepare your datasets using Focoos' data loading utilities
- Flexible Model Architecture: Choose from a variety of pre-built model architectures or customize your own
- Advanced Training Features:
- Mixed precision training for faster training and reduced memory usage
- Automatic learning rate scheduling
- Early stopping and model checkpointing
- Distributed training support
- Experiment Tracking: Monitor training progress, visualize metrics, and compare experiments through the Focoos Hub
In the following sections, we'll guide you through the process of training a model with Focoos, from setting up your environment to deploying your trained model.
๐จ Fine-tune a model in 3 steps#
In this guide, we will perform the following steps:
0. [Optional] Connect to the Focoos Hub#
Focoos can be used without having an accont on the Focoos Hub. With it, you will unlock additional functionalities, as we will see below. If you have it, just connect to the HUB.
1 2 3 4 |
|
1. Select dataset#
Before starting the training, we need to get a dataset. You can either use a local dataset or you can download one from the hub.
[Optional] Download the data from the Hub#
If you want to download a dataset from the hub, you can use it to directly store it in your local environment. Check the reference of your dataset on the platform and use it in the following cell. If you want to try an example dataset, just use one of the many available on the Focoos Hub.
1 2 3 4 5 |
|
Get the training dataset#
Now that we downloaded the dataset, we can magically ๐ช instanciate the dataset using the AutoDataset
as will be used in the training. You can optionally specify aumgentations for the training using the DatasetAugmentation
dataclass.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
2. Train the Model#
Instanciate a model#
The first step to personalize your model is to instance a model. You can get a model using the ModelManager by specifying a model name. Optionally, you can also get one of your trained models on the hub. If you want to follow the example, just use fai-detr-m-coco
as the model reference.
1 2 3 4 |
|
Select the hyper-parameters#
The next step is to create a TrainerArgs
with the hyper-parameters such as the learning rate, the number of iterations and so on.
Optionally, if you are using the hub, you can specify sync_to_hub=True
to track the experiment on the Focoos Hub.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Train the model#
Now we are set up. We can directly call the train function of the model.
1 |
|
3. Test the Model#
Now that the model is ready, let's see how it behaves.
1 2 3 4 5 6 7 8 9 10 11 12 |
|