Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ruhyadi/yolov5-registry


https://github.com/ruhyadi/yolov5-registry

Last synced: about 10 hours ago
JSON representation

Awesome Lists containing this project

README

        

# CVAT Model Registry Template

CVAT
nuclio
nuclio-debug

A template to kickstart cvat model deployment

Click on [Use this template](https://github.com/ashleve/lightning-hydra-template/generate) to initialize new repository.

## 📌  Introduction
The template can be used as a model registry for the model to be deployed to CVAT. This template contains several scripts (`main.py`, `model_handler.py`, `ci.yaml`, etc) you must customize according to the model used. This template also uses CI mechanisms to: build docker images; debug models in Nuclio; and delete GitHub releases when CI failure.

![ci](assets/ci.png)

An example of using this template to develop a registry model can be seen on the branch:

- YOLOv5
- YOLOR
- DETR

## 🚀  Quickstart
You can clone the repository and put the script dependency model in it.
```bash
git clone https://github.com/ruhyadi/model-registry-cvat-template ./your_model
cd ./your_model

git clone https://github.com/username/your_model ./
```
You must configure three important scripts to deploy the model to cvat: `main.py`, `model_handler.py`, and `function.yaml`.

### Main Script (`main.py`)

`main.py` is a script used to initiate and inference models. Inside `main.py` there are two functions: `init_context` and `handler`.The `init_context` function initiates the model, while the `handler` function is used for the inference model. The goal of `main.py` is to generate a response as `json`.

The author has provided a `#TODO` that you can follow along:
1. In the `init_context` function, load `model` according to the load model function of `model_handler`.
2. In the `handler` function, change the message in `context.logger.info()`.
3. Set the desired threshold value (default: 0.5).
4. Change the inference model mechanism; the final result will be `results` which contains a dictionary (NOTE: for object detection task):
```yaml
results = {
"confidence": 0.8,
"label": "car",
"xmin": 0.1,
"ymin": 0.2,
"xmax": 0.3,
"ymax": 0.4,
}
```

### Model Handler (`model_handler.py`)

The purpose of `model_handler.py` is to simplify the process of loading and inference models. This process will usually require script dependencies according to each model. There are no special write conditions in `model_handler.py`. However, the handler model must be able to be used for this simplification process.

### Function (`function.yaml`)

`function.yaml` contains the configuration that nuclio will use to deploy the model. The `function.yaml` file already contains information about how to fill the file. The parameter `build.baseImage` should be noted here, which contains the docker image. This parameter will be automatically generated by **system model deployment**, so users do not need to change the model version every time there is an update. However, filling in the initial version of the model is still recommended.

```yaml
build:
image: cvat/model-name
baseImage: username/model-name:version # automatic generated
```

### CI/CD (`workflows/ci.yaml`)

The CI/CD function in this template is helps automate:

- build a docker image model (including model weights);
- debug model with nuclio;
- delete release if any of the functions fail.

**GitHub Release** triggers the CI/CD function by including model weights on Assets. GitHub Release can be done quickly using the **Model Registry** function.

## ℹ️  Questions?
Don't hesitate to make an issue.