Skip to content

Examples

aimspot edited this page Aug 21, 2023 · 11 revisions

API example

Illustrative example: Example API

  1. Download the repository and install dependencies
!git clone https://github.com/saaresearch/ODRS.git
%cd ODRS/
!pip install -r requirements.txt 
%cd ..
  1. To use our recommender system, run the following code:
  • job - current task (ml_recommend / object_detection);
  • path - Path to a set of images in yolo format;
  • classes - The name of the txt file containing the name of the classes;
  • gpu - The model will be used on GPU or CPU (True / False);
  • accuracy - If you want max accuracy choose 10. For lower accuracy 1 (1 - 10);
  • speed - If you want max speed choose 5. For lower speed 1 (1 - 5);
from ODRS.ODRS.api.odrs import ODRS
odrs = ODRS(job="ml_recommend", data_path='/media/farm/ssd_1_tb_evo_sumsung/ODRS/user_datasets/yolo/Aerial_Maritime', classes="classes.txt",
              gpu=True, accuracy=10, speed=1)
odrs.fit()
  1. Use the following code to train models:
  • job - current task (ml_recommend / object_detection);
  • path - Path to a set of images in yolo format;
  • classes - The name of the txt file containing the name of the classes;
  • model - The name of the model you want to train ("yolov5l", "yolov5m", "yolov5n", "yolov5s", "yolov5x","yolov7x", "yolov7", "yolov7-tiny", #"yolov8x6", "yolov8x", "yolov8s", "yolov8n", "yolov8m", "faster-rcnn", "ssd");
  • gpu-count - Number of video cards involved in training;
  • select_gpu - Numbers of selected video cards("0,1,2" / "cpu" if gpu-count == 0);
  • config_path - The name of the configuration that will be generated automatically;
from ODRS.ODRS.api.odrs import ODRS
#init object with parameters
odrs_1 = ODRS(job="object_detection", data_path = '/media/farm/ssd_1_tb_evo_sumsung/ODRS/user_datasets/yolo/Aerial_Maritime', classes = "classes.txt",
                img_size = "256", batch_size = "18", epochs = "3",
                model = 'yolov5l', gpu_count = 1, select_gpu = "0", config_path = "dataset.yaml", 
                split_train_value = 0.6, split_test_value = 0.35, split_val_value = 0.05)
# start tranning
odrs_1.fit()

Example

  1. Download the repository and install dependencies
!git clone https://github.com/saaresearch/ODRS.git
cd ODRS/
!pip install -r requirements.txt 

ML Recommendation System

Illustrative example: Example

  1. cd ODRS/;
  2. Put your dataset in yolo format in the user_datasets/yolo directory;
  3. Add to the root directory of the project .txt a file containing the names of all classes in your set of images;
  4. cd ODRS/ml_utils/config/, open file ml_config.yaml and set your parameters;
  5. cd ..;
  6. Run script: python3 ml_model_optimizer.py.

Model traning

Illustrative example: Example

  1. cd ODRS/;
  2. Put your dataset in yolo format in the user_datasets/yolo directory;
  3. Add to the root directory of the project .txt a file containing the names of all classes in your set of images;
  4. cd ODRS/train_utils/config/, open file ml_config.yaml and set your parameters;
  5. cd ..;
  6. Run script: python3 custom_train_all.py .