Skip to content

Instantly share code, notes, and snippets.

View asanakoy's full-sized avatar

Artsiom asanakoy

View GitHub Profile
import os
from os.path import join
import json
import cv2
import numpy as np
from tqdm import tqdm
import json
from pycocotools import mask as maskUtils
from scipy import ndimage
from PIL import Image
import cv2
from pathlib import Path
import os
import re
import pandas as pd
import numpy as np
from tqdm import tqdm
def main(input_dirs, output_dir):
@asanakoy
asanakoy / rgb_2_suv.py
Last active August 30, 2023 09:23
Convert from RGB to SUV color space
import numpy as np
from scipy.signal import convolve
from numpy import linalg
# implementation of RGB2SUV http://vision.ucsd.edu/~spmallick/research/suv/index.html
def get_rot_mat(rot_v, unit=None):
@asanakoy
asanakoy / Scrape with proxy
Created October 12, 2018 19:11
How to scrape data fwom awebsite through proxies
#Proxy list graper
# https://github.com/abdallahelsokary/Proxy-Collector-/blob/master/Proxy_Collector.py
import urllib.request
import urllib.error
import time
def proxy_list():
try:
Collecting horovod
Using cached horovod-0.10.1.tar.gz
Building wheels for collected packages: horovod
Running setup.py bdist_wheel for horovod: started
Running setup.py bdist_wheel for horovod: still running...
Running setup.py bdist_wheel for horovod: finished with status 'error'
Complete output from command /beegfs/home/hd/hd_hd/hd_tn445/.venvs/tf_r1/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/hd_tn445_job_5405240/pip-build-o4EglG/horovod/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/hd_tn445_job_5405240/tmpABgSLhpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
@asanakoy
asanakoy / image_scatter.py
Created September 26, 2016 15:03 — forked from lukemetz/image_scatter.py
Image tsne scatter plot
from tsne import bh_sne
import numpy as np
from skimage.transform import resize
from matplotlib import pyplot as plt
def gray_to_color(img):
if len(img.shape) == 2:
img = np.dstack((img, img, img))
return img
@asanakoy
asanakoy / alexnet_netspec.py
Last active July 24, 2018 15:29
Generate caffe netspec file for Alexnet model
# 23.03.16, Artsiom Sanakoyeu
import caffe
from caffe import layers as L, params as P
def alexnet(train_data_source, test_data_source, mean_file, train_batch_size=128, test_batch_size=50, database_backend=P.Data.LEVELDB):
"""
Generate the caffe's network specification train_val.prototxt file for Alexnet model,
described in the [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks) publication.
"""
@asanakoy
asanakoy / caffe_test_nondeterministic.py
Created December 18, 2015 22:54
Script to show non-deterministic caffe behaviour
from caffeext import *
import caffe
import os.path
from scipy import misc
import time
def run_test_on_images(net, transformer, data, batch_size):
data_blob_shape = net.blobs['data'].data.shape
data_blob_shape = list(data_blob_shape)
name: "art_cnn"
input: "data"
input_shape {
dim: 1
dim: 3
dim: 227
dim: 227
}
layer {
name: "conv1"