Skip to content

Instantly share code, notes, and snippets.

View RomanSteinberg's full-sized avatar

Roman Steinberg RomanSteinberg

  • Vision Systems
  • Rostov-on-Don
View GitHub Profile
@RomanSteinberg
RomanSteinberg / analyze.py
Created November 29, 2018 14:06
TypeForm Analyze
import pandas as pd
import json
# input parameters
quiz_res_file = '/home/roman/temp/pre_survey/quiz_result.csv'
quiz_descr_file = '/home/roman/temp/pre_survey/quiz_description.json'
# main
df = pd.read_csv(quiz_res_file)
description = json.load(open(quiz_descr_file))
@RomanSteinberg
RomanSteinberg / heap.js
Last active September 20, 2018 07:48
Heap and priority queue
class Heap {
constructor() {
this.container = [null];
}
isRoot(ind) {
return ind == 1;
}
swap(ind1, ind2) {
@RomanSteinberg
RomanSteinberg / log_git.py
Created September 18, 2018 13:29
log commit hash
import git
repo = git.Repo(search_parent_directories=True)
opt_file.write('branch: %s\n' % repo.active_branch)
opt_file.write('sha: %s\n' % repo.head.object.hexsha)
@RomanSteinberg
RomanSteinberg / example.py
Last active July 25, 2018 14:32
Estimator fail because of folder
import numpy as np
import tensorflow as tf
experiment_folder = '/output/'
input_shape = [299, 299, 3]
def imgs_input_fn(filenames, labels=None, perform_shuffle=False, repeat_count=1, batch_size=1):
"""
@RomanSteinberg
RomanSteinberg / train.py
Created July 24, 2018 14:20
Dataset + Estimator + Keras Model
from tensorflow.python.keras.models import Model
from tensorflow.python.keras.layers import Dense, Input, Dropout
def imgs_input_fn(filenames, labels=None, perform_shuffle=False, repeat_count=1, batch_size=1):
"""
Creates tf.data.Dataset object.
Args:
filenames (list:
labels (list):
@RomanSteinberg
RomanSteinberg / task.js
Created July 18, 2018 15:51
models/task.js
const Promise = require('bluebird');
const mongoose = require('mongoose');
const _ = require('lodash');
const Answer = require('./answer');
const GooGl = require('./goo-gl');
const Meta = require('./meta');
const Recommendations = require('./recommendations');
const config = require('../config');
@RomanSteinberg
RomanSteinberg / sol
Created July 13, 2018 08:11
solution
function fk(n) {
return (n*(n + 1)) / 2;
}
var data = readline().split(' ').map(function(x) { return parseInt(x); });
var n = data[0];
var m = data[1];
var k = data[2];
var nL = k - 1;
@RomanSteinberg
RomanSteinberg / preproc.py
Created July 9, 2018 13:47
preprocessing
import tensorflow as tf
from imageio import imsave, imread
def read_and_preproc():
inp_img_op = tf.placeholder(tf.float32, shape=[None, None, 3])
image_size_before_crop, IMG_HEIGHT, IMG_WIDTH = 286, 256, 256
# Preprocessing:
out = tf.image.resize_images(inp_img_op, [image_size_before_crop, image_size_before_crop])
out = tf.random_crop(out, [IMG_HEIGHT, IMG_WIDTH, 3])
@RomanSteinberg
RomanSteinberg / start.py
Created July 6, 2018 15:04
start_queue_runners
import tensorflow as tf
from glob import glob
folder = './data/*.jpg'
def create_graph():
filename_queue = tf.train.string_input_producer(list(glob(folder)))
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
@RomanSteinberg
RomanSteinberg / img_helpers.py
Last active May 28, 2018 14:40
CPU and GPU Tensorflow comparisons
# -*- coding: utf-8 -*-
import numpy as np
from glob import glob
import tensorflow.contrib.keras as K
from skimage.util import view_as_windows, pad
resnet = K.applications.resnet50
image = K.preprocessing.image