id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
189,060
from typing import TYPE_CHECKING from django.conf import settings def is_root_user(*, request: "HttpRequest", user: "User") -> bool: root = ( hasattr(settings, "ROOT_USER") and request.user != user and user.username == settings.ROOT_USER ) demo = ( getattr(settings, "DEMO", ...
null
189,061
from django.db import migrations def link_agents_to_users(apps, schema_editor): Agent = apps.get_model("agents", "Agent") User = apps.get_model("accounts", "User") for agent in Agent.objects.all(): user = User.objects.filter(username=agent.agent_id).first() if user: user.agent ...
null
189,062
import django.db.models.deletion from django.db import migrations, models def delete_alerts_without_agent(apps, schema): Alert = apps.get_model("alerts", "Alert") Alert.objects.filter(agent=None).delete()
null
189,063
from typing import TYPE_CHECKING from django.shortcuts import get_object_or_404 from rest_framework import permissions from tacticalrmm.permissions import _has_perm, _has_perm_on_agent class Alert(models.Model): objects = PermissionQuerySet.as_manager() agent = models.ForeignKey( "agents.Agent", ...
null
189,064
from django.utils import timezone as djangotime from agents.models import Agent from tacticalrmm.celery import app from .models import Alert class Alert(models.Model): objects = PermissionQuerySet.as_manager() agent = models.ForeignKey( "agents.Agent", related_name="agent", on_delete=m...
null
189,065
from django.utils import timezone as djangotime from agents.models import Agent from tacticalrmm.celery import app from .models import Alert class Agent(BaseAuditModel): class Meta: indexes = [ models.Index(fields=["monitoring_type"]), ] objects = PermissionQuerySet.as_manager() ...
null
189,066
import random from django.conf import settings from tacticalrmm.structs import AgentCheckInConfig def get_agent_config() -> AgentCheckInConfig: return AgentCheckInConfig( checkin_hello=random.randint(*getattr(settings, "CHECKIN_HELLO", (30, 60))), checkin_agentinfo=random.randint( *geta...
null
189,067
import json import subprocess import tempfile import urllib.parse from base64 import b64encode from typing import TYPE_CHECKING, Optional, cast import requests import websockets from django.conf import settings from django.core.cache import cache from django.http import FileResponse from meshctrl.utils import get_auth_...
null
189,068
import json import subprocess import tempfile import urllib.parse from base64 import b64encode from typing import TYPE_CHECKING, Optional, cast import requests import websockets from django.conf import settings from django.core.cache import cache from django.http import FileResponse from meshctrl.utils import get_auth_...
null
189,069
import json import subprocess import tempfile import urllib.parse from base64 import b64encode from typing import TYPE_CHECKING, Optional, cast import requests import websockets from django.conf import settings from django.core.cache import cache from django.http import FileResponse from meshctrl.utils import get_auth_...
null
189,070
import json import subprocess import tempfile import urllib.parse from base64 import b64encode from typing import TYPE_CHECKING, Optional, cast import requests import websockets from django.conf import settings from django.core.cache import cache from django.http import FileResponse from meshctrl.utils import get_auth_...
null
189,071
from django.db import migrations def update_hide_in_summary(apps, schema_editor): CustomField = apps.get_model("core", "CustomField") for field in CustomField.objects.filter(hide_in_ui=True): field.hide_in_summary = True field.save(update_fields=["hide_in_summary"])
null
189,072
import json from django.conf import settings from django.http import HttpResponse def monitoring_view(function): def wrap(request, *args, **kwargs): if request.method != "POST": return HttpResponse("Invalid request type\n", status=400) try: data = json.loads(request.body) ...
null
189,073
import asyncio import traceback from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Any import nats from django.conf import settings from django.db import transaction from django.db.models import Prefetch from django.db.utils import DatabaseError from django.utils import timezone as...
null
189,074
import asyncio import traceback from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Any import nats from django.conf import settings from django.db import transaction from django.db.models import Prefetch from django.db.utils import DatabaseError from django.utils import timezone as...
null
189,075
import asyncio import traceback from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Any import nats from django.conf import settings from django.db import transaction from django.db.models import Prefetch from django.db.utils import DatabaseError from django.utils import timezone as...
null
189,076
import asyncio import traceback from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Any import nats from django.conf import settings from django.db import transaction from django.db.models import Prefetch from django.db.utils import DatabaseError from django.utils import timezone as...
null
189,077
import asyncio import traceback from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Any import nats from django.conf import settings from django.db import transaction from django.db.models import Prefetch from django.db.utils import DatabaseError from django.utils import timezone as...
null
189,078
import asyncio import traceback from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Any import nats from django.conf import settings from django.db import transaction from django.db.models import Prefetch from django.db.utils import DatabaseError from django.utils import timezone as...
null
189,079
import json import re from contextlib import suppress from pathlib import Path from zoneinfo import ZoneInfo import psutil import requests from cryptography import x509 from django.conf import settings from django.http import JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone ...
null
189,080
import json import re from contextlib import suppress from pathlib import Path from zoneinfo import ZoneInfo import psutil import requests from cryptography import x509 from django.conf import settings from django.http import JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone ...
null
189,081
import json import re from contextlib import suppress from pathlib import Path from zoneinfo import ZoneInfo import psutil import requests from cryptography import x509 from django.conf import settings from django.http import JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone ...
null
189,082
import json import re from contextlib import suppress from pathlib import Path from zoneinfo import ZoneInfo import psutil import requests from cryptography import x509 from django.conf import settings from django.http import JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone ...
null
189,083
import json import re from contextlib import suppress from pathlib import Path from zoneinfo import ZoneInfo import psutil import requests from cryptography import x509 from django.conf import settings from django.http import JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone ...
null
189,084
from django.db import migrations def link_sites_to_agents(apps, schema_editor): Agent = apps.get_model("agents", "Agent") Site = apps.get_model("clients", "Site") for agent in Agent.objects.all(): site = Site.objects.get(client__client=agent.client, site=agent.site) agent.site_link = site ...
null
189,085
from django.db import migrations def reverse(apps, schema_editor): Agent = apps.get_model("agents", "Agent") for agent in Agent.objects.all(): agent.site = agent.site_link.site agent.client = agent.site_link.client.client agent.save()
null
189,086
import datetime as dt from time import sleep from typing import TYPE_CHECKING, Optional from django.core.management import call_command from django.utils import timezone as djangotime from agents.models import Agent from core.utils import get_core_settings from logs.models import DebugLog from scripts.models import Scr...
null
189,087
import datetime as dt from time import sleep from typing import TYPE_CHECKING, Optional from django.core.management import call_command from django.utils import timezone as djangotime from agents.models import Agent from core.utils import get_core_settings from logs.models import DebugLog from scripts.models import Scr...
null
189,088
import datetime as dt from time import sleep from typing import TYPE_CHECKING, Optional from django.core.management import call_command from django.utils import timezone as djangotime from agents.models import Agent from core.utils import get_core_settings from logs.models import DebugLog from scripts.models import Scr...
null
189,089
import datetime as dt from time import sleep from typing import TYPE_CHECKING, Optional from django.core.management import call_command from django.utils import timezone as djangotime from agents.models import Agent from core.utils import get_core_settings from logs.models import DebugLog from scripts.models import Scr...
null
189,090
import datetime as dt from time import sleep from typing import TYPE_CHECKING, Optional from django.core.management import call_command from django.utils import timezone as djangotime from agents.models import Agent from core.utils import get_core_settings from logs.models import DebugLog from scripts.models import Scr...
null
189,091
import datetime as dt from time import sleep from typing import TYPE_CHECKING, Optional from django.core.management import call_command from django.utils import timezone as djangotime from agents.models import Agent from core.utils import get_core_settings from logs.models import DebugLog from scripts.models import Scr...
null
189,092
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,093
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,094
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,095
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,096
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,097
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,098
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,099
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,100
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,101
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,102
import asyncio import datetime as dt import random import string import time from io import StringIO from pathlib import Path from django.conf import settings from django.db.models import Exists, OuterRef, Prefetch, Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils ...
null
189,103
import json import os import secrets import string from itertools import cycle from django.conf import settings from django.utils import timezone as djangotime from model_bakery.recipe import Recipe, foreign_key, seq from tacticalrmm.constants import AgentMonType, AgentPlat def generate_agent_id() -> str: return "...
null
189,104
import json import os import secrets import string from itertools import cycle from django.conf import settings from django.utils import timezone as djangotime from model_bakery.recipe import Recipe, foreign_key, seq from tacticalrmm.constants import AgentMonType, AgentPlat def get_wmi_data(): with open( o...
null
189,105
import json import os import secrets import string from itertools import cycle from django.conf import settings from django.utils import timezone as djangotime from model_bakery.recipe import Recipe, foreign_key, seq from tacticalrmm.constants import AgentMonType, AgentPlat def get_win_svcs(): svcs = settings.BASE...
null
189,106
import asyncio from typing import Any from django.shortcuts import get_object_or_404 from rest_framework.decorators import api_view from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView from agents.models import Agent from logs.model...
null
189,107
def bytes2human(n: int) -> str: # http://code.activestate.com/recipes/578019 symbols = ("K", "M", "G", "T", "P", "E", "Z", "Y") prefix = {} for i, s in enumerate(symbols): prefix[s] = 1 << (i + 1) * 10 for s in reversed(symbols): if n >= prefix[s]: value = float(n) / pr...
null
189,108
from django.db import migrations, transaction from django.db.utils import IntegrityError from tacticalrmm.constants import CheckType def migrate_check_results(apps, schema_editor): Check = apps.get_model("checks", "Check") CheckResult = apps.get_model("checks", "CheckResult") for check in Check.objects.exc...
null
189,109
import datetime as dt from time import sleep from typing import Optional from django.utils import timezone as djangotime from alerts.models import Alert from checks.models import CheckResult from tacticalrmm.celery import app from tacticalrmm.helpers import rand_range class Alert(models.Model): objects = Permissio...
null
189,110
import datetime as dt from time import sleep from typing import Optional from django.utils import timezone as djangotime from alerts.models import Alert from checks.models import CheckResult from tacticalrmm.celery import app from tacticalrmm.helpers import rand_range class Alert(models.Model): objects = Permissio...
null
189,111
import datetime as dt from time import sleep from typing import Optional from django.utils import timezone as djangotime from alerts.models import Alert from checks.models import CheckResult from tacticalrmm.celery import app from tacticalrmm.helpers import rand_range class Alert(models.Model): objects = Permissio...
null
189,112
import datetime as dt from time import sleep from typing import Optional from django.utils import timezone as djangotime from alerts.models import Alert from checks.models import CheckResult from tacticalrmm.celery import app from tacticalrmm.helpers import rand_range class Alert(models.Model): def __str__(self) ...
null
189,113
import asyncio from datetime import datetime as dt from django.db.models import Prefetch, Q from django.shortcuts import get_object_or_404 from django.utils import timezone as djangotime from rest_framework.decorators import api_view, permission_classes from rest_framework.exceptions import PermissionDenied from rest_f...
null
189,114
import asyncio from datetime import datetime as dt from django.db.models import Prefetch, Q from django.shortcuts import get_object_or_404 from django.utils import timezone as djangotime from rest_framework.decorators import api_view, permission_classes from rest_framework.exceptions import PermissionDenied from rest_f...
null
189,115
from abc import abstractmethod from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union, cast from django.db import models from core.utils import get_core_settings from tacticalrmm.constants import ( AuditActionType, AuditObjType, DebugLogLevel, DebugLogType, PAAction, PAStatus, ) fro...
null
189,116
from django.core.exceptions import ObjectDoesNotExist from django.db import migrations def update_agent_field(apps, schema_editor): AuditLog = apps.get_model("logs", "AuditLog") Agent = apps.get_model("agents", "Agent") for log in AuditLog.objects.exclude(agent_id=None): try: log.agent_...
null
189,117
import datetime as dt from django.db.models.signals import post_init from django.dispatch import receiver from tacticalrmm.constants import PAAction, PAStatus from tacticalrmm.helpers import date_is_in_past from .models import PendingAction class PendingAction(models.Model): objects = PermissionQuerySet.as_manager...
null
189,118
from tacticalrmm.celery import app class AutomatedTask(BaseAuditModel): def __str__(self) -> str: def save(self, *args, **kwargs) -> None: def delete(self, *args, **kwargs): def schedule(self) -> Optional[str]: def fields_that_trigger_task_update_on_agent(self) -> List[str]: def serialize...
null
189,119
import uuid from typing import Dict from django.contrib.postgres.fields import ArrayField from django.core.cache import cache from django.db import models from agents.models import Agent from logs.models import BaseAuditModel from tacticalrmm.constants import AGENT_DEFER, AgentMonType, CustomFieldType, GoArch from tact...
null
189,120
from django.db import migrations from tacticalrmm.constants import GoArch def change_arch(apps, schema_editor): Deployment = apps.get_model("clients", "Deployment") for d in Deployment.objects.all(): if d.arch == "64": d.arch = GoArch.AMD64 else: d.arch = GoArch.i386 ...
null
189,121
import asyncio from typing import Dict, Tuple, Union from django.conf import settings from django.shortcuts import get_object_or_404 from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView from agents.models import Agent from tacticalr...
null
189,122
import asyncio from django.shortcuts import get_object_or_404 from rest_framework.decorators import api_view, permission_classes from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView from django.conf import settings from agents.permi...
null
189,123
import asyncio import datetime as dt import time from contextlib import suppress from zoneinfo import ZoneInfo from django.utils import timezone as djangotime from packaging import version as pyver from agents.models import Agent from logs.models import DebugLog from tacticalrmm.celery import app from tacticalrmm.const...
null
189,124
import asyncio import datetime as dt import time from contextlib import suppress from zoneinfo import ZoneInfo from django.utils import timezone as djangotime from packaging import version as pyver from agents.models import Agent from logs.models import DebugLog from tacticalrmm.celery import app from tacticalrmm.const...
null
189,125
from django.db import migrations from django.utils.timezone import make_aware from tacticalrmm.constants import TaskType def migrate_script_data(apps, schema_editor): AutomatedTask = apps.get_model("autotasks", "AutomatedTask") # convert autotask to the new format for task in AutomatedTask.objects.all(): ...
null
189,126
from django.db import migrations from django.db.models import Count from autotasks.models import generate_task_name from tacticalrmm.constants import TaskSyncStatus def generate_task_name() -> str: chars = string.ascii_letters return "TacticalRMM_" + "".join(random.choice(chars) for i in range(35)) def check_...
null
189,127
from django.db import migrations, transaction from django.db.utils import IntegrityError def migrate_task_results(apps, schema_editor): AutomatedTask = apps.get_model("autotasks", "AutomatedTask") TaskResult = apps.get_model("autotasks", "TaskResult") for task in AutomatedTask.objects.exclude(agent=None): ...
null
189,128
from django.db import migrations def migrate_env_vars(apps, schema_editor): AutomatedTask = apps.get_model("autotasks", "AutomatedTask") for task in AutomatedTask.objects.iterator(chunk_size=30): try: tmp = [] if isinstance(task.actions, list) and task.actions: f...
null
189,129
from django.db import migrations from tacticalrmm.utils import get_bit_days DAYS_OF_WEEK = { 0: "Monday", 1: "Tuesday", 2: "Wednesday", 3: "Thursday", 4: "Friday", 5: "Saturday", 6: "Sunday", } def migrate_days(apps, schema_editor): AutomatedTask = apps.get_model("autotasks", "Automated...
null
189,130
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,131
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,132
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,133
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,134
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,135
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,136
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,137
import asyncio import datetime as dt from collections import namedtuple from contextlib import suppress from time import sleep from typing import TYPE_CHECKING, Optional, Union import msgpack import nats from django.utils import timezone as djangotime from nats.errors import TimeoutError from agents.models import Agent...
null
189,138
import re import setuptools import sys def get_package_dir(): pkg_dir = { "yolox.tools": "tools", "yolox.exp.default": "exps/default", } return pkg_dir
null
189,139
import re import setuptools import sys def get_install_requirements(): with open("requirements.txt", "r", encoding="utf-8") as f: reqs = [x.strip() for x in f.read().splitlines()] reqs = [x for x in reqs if not x.startswith("#")] return reqs
null
189,140
import re import setuptools import sys def get_yolox_version(): with open("yolox/__init__.py", "r") as f: version = re.search( r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE ).group(1) return version
null
189,141
import re import setuptools import sys def get_long_description(): with open("README.md", "r", encoding="utf-8") as f: long_description = f.read() return long_description
null
189,142
import re import setuptools import sys TORCH_AVAILABLE = True def get_ext_modules(): ext_module = [] if sys.platform != "win32": # pre-compile ops on linux assert TORCH_AVAILABLE, "torch is required for pre-compiling ops, please install it first." # if any other op is added, please also add it...
null
189,143
import re import setuptools import sys TORCH_AVAILABLE = True def get_cmd_class(): cmdclass = {} if TORCH_AVAILABLE: cmdclass["build_ext"] = cpp_extension.BuildExtension return cmdclass
null
189,144
import os import sys from unittest import mock from sphinx.domains import Domain from typing import Dict, List, Tuple import sphinx_rtd_theme class GithubURLDomain(Domain): def resolve_any_xref(self, env, fromdocname, builder, target, node, contnode): from recommonmark.parser import CommonMarkParser import yolox ...
null
189,145
import os import random import torch import torch.distributed as dist import torch.nn as nn from .base_exp import BaseExp class Exp(BaseExp): def __init__(self): super().__init__() # ---------------- model config ---------------- # # detect classes number of model self.num_classes = ...
null
189,148
import contextlib import io import itertools import json import tempfile import time from collections import ChainMap, defaultdict from loguru import logger from tabulate import tabulate from tqdm import tqdm import numpy as np import torch from yolox.data.datasets import COCO_CLASSES from yolox.utils import ( gath...
null
189,149
import os import pickle import xml.etree.ElementTree as ET import numpy as np def parse_rec(filename): """Parse a PASCAL VOC xml file""" tree = ET.parse(filename) objects = [] for obj in tree.findall("object"): obj_struct = {} obj_struct["name"] = obj.find("name").text obj_struct...
null
189,154
import bisect import copy import os import random from abc import ABCMeta, abstractmethod from functools import partial, wraps from multiprocessing.pool import ThreadPool import psutil from loguru import logger from tqdm import tqdm import numpy as np from torch.utils.data.dataset import ConcatDataset as torchConcatDat...
null
189,155
import copy import os import cv2 import numpy as np from pycocotools.coco import COCO from ..dataloading import get_yolox_datadir from .datasets_wrapper import CacheDataset, cache_read_img The provided code snippet includes necessary dependencies for implementing the `remove_useless_info` function. Write a Python func...
Remove useless info in coco dataset. COCO object is modified inplace. This function is mainly used for saving memory (save about 30% mem).
189,169
import torch from torch import nn from torch.hub import load_state_dict_from_url def create_yolox_model(name: str, pretrained: bool = True, num_classes: int = 80, device=None, exp_path: str = None, ckpt_path: str = None) -> nn.Module: """creates and loads a YOLOX model Args: name ...
null
189,182
import os import random import cv2 import numpy as np def random_color(): return random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) The provided code snippet includes necessary dependencies for implementing the `visualize_assign` function. Write a Python function `def visualize_assign(img, boxe...
visualize label assign result. Args: img: img to visualize boxes: gt boxes in xyxy format coords: coords of matched anchors match_results: match results of each gt box and coord. save_name: name of save image, if None, image will not be saved. Default: None.
189,183
import os import random import cv2 import numpy as np def mkdir(path): if not os.path.exists(path): os.makedirs(path)
null
189,184
import os import random import cv2 import numpy as np def multiclass_nms_class_aware(boxes, scores, nms_thr, score_thr): """Multiclass NMS implemented in Numpy. Class-aware version.""" final_dets = [] num_classes = scores.shape[1] for cls_ind in range(num_classes): cls_scores = scores[:, cls_ind...
Multiclass NMS implemented in Numpy
189,185
import os import random import cv2 import numpy as np def demo_postprocess(outputs, img_size, p6=False): grids = [] expanded_strides = [] strides = [8, 16, 32] if not p6 else [8, 16, 32, 64] hsizes = [img_size[0] // stride for stride in strides] wsizes = [img_size[1] // stride for stride in stride...
null
189,199
import functools import os import time from collections import defaultdict, deque import psutil import numpy as np import torch def get_total_and_free_memory_in_Mb(cuda_device): devices_info_str = os.popen( "nvidia-smi --query-gpu=memory.total,memory.used --format=csv,nounits,noheader" ) devices_inf...
pre-allocate gpu memory for training to avoid memory Fragmentation.
189,200
import functools import os import time from collections import defaultdict, deque import psutil import numpy as np import torch The provided code snippet includes necessary dependencies for implementing the `gpu_mem_usage` function. Write a Python function `def gpu_mem_usage()` to solve the following problem: Compute ...
Compute the GPU memory usage for the current device (MB).
189,201
import functools import os import time from collections import defaultdict, deque import psutil import numpy as np import torch The provided code snippet includes necessary dependencies for implementing the `mem_usage` function. Write a Python function `def mem_usage()` to solve the following problem: Compute the memo...
Compute the memory usage for the current machine (GB).
189,211
import numpy as np import torch import torchvision def cxcywh2xyxy(bboxes): bboxes[:, 0] = bboxes[:, 0] - bboxes[:, 2] * 0.5 bboxes[:, 1] = bboxes[:, 1] - bboxes[:, 3] * 0.5 bboxes[:, 2] = bboxes[:, 0] + bboxes[:, 2] bboxes[:, 3] = bboxes[:, 1] + bboxes[:, 3] return bboxes
null
189,212
import argparse import logging as log import os import sys import cv2 import numpy as np from openvino.inference_engine import IECore from yolox.data.data_augment import preproc as preprocess from yolox.data.datasets import COCO_CLASSES from yolox.utils import mkdir, multiclass_nms, demo_postprocess, vis The provided ...
Parse and return command line arguments