Skip to content

Instantly share code, notes, and snippets.

View nijkah's full-sized avatar

Hakjin Lee nijkah

View GitHub Profile
from mmdet.registry import MODELS
from mmdet.utils import register_all_modules
from mmengine.config import Config
import torch
mmdet_config_path = 'configs/rtdetr/rtdetr_r18vd_dec3_8xb2-72e_coco.py'
model_weight_file = 'rtdetr_r50vd_6x_coco_mmdet.pth'
"""
# convert pdparams to torch tensors
@nijkah
nijkah / show_containers_using_gpu.py
Created September 7, 2022 01:00
List docker containers using GPU
import os
def shell(command):
stream = os.popen(command)
out = stream.read().split("\n")[:-1]
return out
def find_docker(pid: int):
if pid == -1:
return -1, "No Docker!"
@nijkah
nijkah / convert_import_paths.py
Created May 13, 2021 14:40
This code converts code for import relative module to absolute path in all files.
import os
import sys
from pathlib import Path
import fileinput
def get_all_files(parent_folder):
return list(Path(parent_folder).rglob("*"))
@nijkah
nijkah / multiprocessing_connection.py
Last active December 3, 2020 05:17
Allow sending more than 2 GB at once on a multiprocessing connection on non-Windows systems. https://stackoverflow.com/questions/47776486/python-struct-error-i-format-requires-2147483648-number-2147483647
#
# A higher level module for using sockets (or Windows named pipes)
#
# multiprocessing/connection.py
#
# Copyright (c) 2006-2008, R Oudkerk
# Licensed to PSF under a Contributor Agreement.
#
__all__ = [ 'Client', 'Listener', 'Pipe', 'wait' ]