Skip to content

Instantly share code, notes, and snippets.

View wolterlw's full-sized avatar
🇺🇦

Volodymyr wolterlw

🇺🇦
View GitHub Profile
import numpy as np
def get_thresholded_indices(inp_array, threshold=10, radius=30):
y = lambda x: inp_array[x]
population = np.random.randint(0,len(inp_array),len(inp_array))
pop_size = len(population)-1
for delta in range(7,0,-1):
for i in range(100):
@wolterlw
wolterlw / jupyter_tweak.py
Created July 9, 2020 22:47
changes jupyter cell width to 100%
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
@wolterlw
wolterlw / hand_ssh_anchors.cpp
Created September 20, 2019 19:10
c++ program to get anchors needed for hand detection
/*
parameter JSON
{
"num_layers": 5,
"min_scale": 0.1171875,
"max_scale": 0.75,
"input_size_height": 256,
"input_size_width": 256,
"anchor_offset_x": 0.5,
"anchor_offset_y": 0.5,
@wolterlw
wolterlw / tf_changes.diff
Created September 18, 2019 04:33
Changes made to the tensorflow source to enable custom operations
diff --git a/tensorflow/lite/kernels/internal/BUILD b/tensorflow/lite/kernels/internal/BUILD
index 4be3226938..6bc39a7194 100644
--- a/tensorflow/lite/kernels/internal/BUILD
+++ b/tensorflow/lite/kernels/internal/BUILD
@@ -37,6 +37,18 @@ NEON_FLAGS_IF_APPLICABLE = select({
],
})
+cc_library(
+ name = "common",
@wolterlw
wolterlw / tg_notify.sh
Last active January 18, 2019 04:29
Minimal bash script to push messages to telegram via bot API
#!/bin/bash
# 1. create a bot using @BotFather
# 2. create a public channel, add the bot as it's administrator
# 3. fill in the required information below
# 4. do a test run. In the response there will be a chat_id, which is a bunch of numbers
# now it's possible to make the channel private and use chat_id instead of the public name
bot_token=#YOUR_BOT_TOKEN
chat_id=#UR_CHANNEL_ID
api_call="https://api.telegram.org/bot$bot_token/sendMessage"
@wolterlw
wolterlw / shell_stuff.sh
Created January 18, 2019 00:42
Shell stuff
#to match the word between foo and bar use:
$ grep -oP '(?<=foo )\w+(?= bar)' test.txt
import torch.nn as nn
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
@wolterlw
wolterlw / pytorch_template.py
Created January 10, 2019 23:23
PyTorch_Template
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision.datasets.mnist import MNIST
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
import visdom
from collections import OrderedDict
class LeNet5(nn.Module):
@wolterlw
wolterlw / add_sublime_shortcut.py
Created September 10, 2018 16:18 — forked from dshulchevskiy/add_sublime_shortcut.py
Sublime shortcut for jupyter notebook
"""
Sublime shortcuts for jupyter notebook
"""
from jupyter_core.paths import jupyter_config_dir
import os
custom_js_path = os.path.join(jupyter_config_dir(), 'custom', 'custom.js')
custom_path = os.path.join(jupyter_config_dir(), 'custom')
@wolterlw
wolterlw / torch_dataset.py
Created June 13, 2018 12:47
PyTorch dataset template
class CustomDataset(torch.utils.data.Dataset):
def __init__(self):
# TODO
# 1. Initialize file paths or a list of file names.
pass
def __getitem__(self, index):
# TODO
# 1. Read one data from file (e.g. using numpy.fromfile, PIL.Image.open).
# 2. Preprocess the data (e.g. torchvision.Transform).
# 3. Return a data pair (e.g. image and label).