Skip to content

Instantly share code, notes, and snippets.

View Y-T-G's full-sized avatar

Mohammed Yasin Y-T-G

View GitHub Profile
@Y-T-G
Y-T-G / bg_images_yolo.py
Last active March 17, 2024 10:15
Download background images for YOLO model training
# Script to download background image from COCO in YOLO format
# Adapted from https://stackoverflow.com/a/62770484/8061030
from pycocotools.coco import COCO
import requests
import os
DETECTOR_CLASSES = [] # Specify the COCO classes that you are detecting
NUM_IMAGES = # Number of background images to download
@Y-T-G
Y-T-G / patched_predictions.py
Created August 16, 2023 17:07
MMDetection 3.1.0 patched _predict_by_feat_single() method to get class probabilities
def _predict_by_feat_single(self,
cls_score_list: List[Tensor],
bbox_pred_list: List[Tensor],
score_factor_list: List[Tensor],
mlvl_priors: List[Tensor],
img_meta: dict,
cfg: ConfigDict,
rescale: bool = False,
with_nms: bool = True) -> InstanceData:
"""Transform a single image's features extracted from the head into
@Y-T-G
Y-T-G / init_model.py
Created November 25, 2023 06:17
Reinitializing MMDetection model in Runner without reloading data.
def init_model(runner):
"""
Initializes a new model for the next training cycle.
Args:
runner (Runner): Runner object.
Returns:
runner (Runner): Runner object with initialized model.
"""
@Y-T-G
Y-T-G / add_head.patch
Last active June 18, 2024 03:24
Patches the YOLO ultralytics library to support extra head for additional classes.
From e41525e084a6f77980665da715ec93070c397479 Mon Sep 17 00:00:00 2001
From: Y-T-G <>
Date: Sat, 16 Mar 2024 14:06:25 +0800
Subject: [PATCH] Add ConcatHead
---
ultralytics/cfg/models/v8/yolov8n-2xhead.yaml | 55 ++++++++++++++++
ultralytics/engine/trainer.py | 2 +-
ultralytics/nn/modules/__init__.py | 2 +
ultralytics/nn/modules/conv.py | 64 +++++++++++++++++++
@Y-T-G
Y-T-G / YOLOv8-CBAM-Involution.patch
Created May 27, 2024 11:47
YOLOv8 port of CBAM and Involution modules by @aash1999
From 1bc48504b6ecebcdc19242f9e99adf5079e7d568 Mon Sep 17 00:00:00 2001
From: Y-T-G <>
Date: Mon, 27 May 2024 19:44:28 +0800
Subject: [PATCH] Port CBAM and Involution by @aash1999
---
.../models/v8/yolov8-cbam-involution-p2.yaml | 57 ++++++++
.../cfg/models/v8/yolov8-cbam-involution.yaml | 49 +++++++
ultralytics/nn/modules/__init__.py | 2 +
ultralytics/nn/modules/conv.py | 123 +++++++++++++++---