Skip to content

Instantly share code, notes, and snippets.

View botcs's full-sized avatar

Csaba Botos botcs

  • PhD @ Torr Vision Group
  • Oxford, UK
View GitHub Profile
import torch
class MicroCluster:
def __init__(self, x, label, max_radius=0.1):
self.N = 1
self.LS = x.clone()
self.SS = x.pow(2)
self.label = label
self.max_radius = max_radius
import torch
import time
import numpy as np
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from microcluster_module import MClassification
def generate_data(n_samples=1000, n_features=2, centers=5):
X, y = make_blobs(n_samples=n_samples, n_features=n_features, centers=centers, random_state=42)
import torch
class MicroCluster:
def __init__(self, x, label, max_radius=0.1):
self.N = 1
self.LS = x.clone()
self.SS = x.pow(2)
self.label = label
self.max_radius = max_radius
class FinalScoreAnnotator:
"""
1) Adds annotations of the last values of the curves
2) Aligns the annotations of the plot to avoid overlaps using L-BFGS-B
Usage:
Has the same signature and functionality as the plt.plot or ax.plot
"""
def __init__(self, ax=None):
from PIL import Image
import numpy as np
import torch
import torchvision.transforms.functional as F
from torchvision import transforms as T
from torchvision.transforms.functional import _interpolation_modes_from_int, InterpolationMode
import math
from torchvision.transforms.transforms import _setup_size, _log_api_usage_once
from collections.abc import Sequence
from typing import List, Optional, Tuple, Union
432908 <empty>
432909 <empty>
432910 <empty>
432911 <empty>
432912 <empty>
432913 <empty>
432914 <empty>
432915 <empty>
432916 <empty>
432917 <empty>
@botcs
botcs / io_benchmark.sh
Created June 14, 2023 02:01
measuring IO with 1k samples of 1MB
#!/bin/bash
directory=$1 # Replace with your designated directory
# Function to measure write time
measure_write_time() {
local file="$1"
local start_time=$(date +%s%N)
dd if=/dev/zero of="$file" bs=1M count=1 status=none
local end_time=$(date +%s%N)
bottom_up_features, expt_flops, real_flops, gate_tensor = self.backbone(x, step_rate)
File "/data/engs-tvg-depth/csbotos/miniconda3/envs/dyndet/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/csbotos/github/fbscript/DynamicRouting/./dl_lib/modeling/dynamic_arch/dynamic_backbone.py", line 300, in forward
self.all_cell_list[layer_index][_cell_index](
File "/data/engs-tvg-depth/csbotos/miniconda3/envs/dyndet/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/csbotos/github/fbscript/DynamicRouting/./dl_lib/modeling/dynamic_arch/dynamic_cell.py", line 273, in forward
result_list[2].append(h_l_down * gate_weights_beta_down)
(function _print_stack)
@botcs
botcs / delayed_mirror.py
Last active April 22, 2020 18:17
a delayed mirror with minimal rewind functionality
import numpy as np
import cv2
import time
cap = cv2.VideoCapture(0)
FRAME_DELAY = 120
cv2.namedWindow('frame', cv2.WINDOW_FREERATIO)
# cv2.setWindowProperty('frame', cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.