Skip to content

Instantly share code, notes, and snippets.

View imneonizer's full-sized avatar
:octocat:
Developing for the python community!

Nitin Rai imneonizer

:octocat:
Developing for the python community!
View GitHub Profile
version: '3'
services:
api:
image: imneonizer/autolycus:api
container_name: autolycus_api
ports:
- 5000:5000
volumes:
- ./downloads:/downloads
@imneonizer
imneonizer / generate_colors.py
Created July 7, 2021 06:43
Generate consistent random colors
import random
import colorsys
def generate_colors(n):
random.seed(10101)
hsv_tuples = [(x / n, 1., 1.) for x in range(n)]
colors = list(map(lambda x: colorsys.hsv_to_rgb(*x), hsv_tuples))
colors = list(map(lambda x: (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)), colors))
random.shuffle(colors)
random.seed(None)
# https://github.com/yogin16/prototxt_parser
# pip install parsy==1.3.0
from parsy import generate, regex, string
# Convert an array of tuples array [[(a,b),(a,c)]] to an object {a: [b,c]}
def tuples_to_dict(a):
# print(a)
new_dict = {}
for tuples in a:
# https://github.com/linghu8812/blur_detector/blob/master/blur_detector.py
import cv2
import numpy as np
class BlurDetector(object):
def __init__(self):
"""Initialize a DCT based blur detector"""
@imneonizer
imneonizer / main.py
Created May 2, 2021 10:36
Custom waitKey for opencv
# make sure terminal window is active when pressing any key
import cv2
import numpy as np
import time
from waitKey import waitKey
frame = np.zeros((300, 300, 3))
idx, st = 0, time.time()
while True:
@imneonizer
imneonizer / hash_engine.py
Created May 1, 2021 18:36
Image hashing techniques
import os
import cv2
import hashlib
import numpy as np
import scipy.fftpack
class HashEngine:
def __init__(self, htype="dhash", hash_size=8):
self.hash_size = hash_size
self.htype = htype
# use multiple gpu devices by index
import os
#GPU_id = '0'
GPU_id = '0,1,2,3'
os.environ['CUDA_VISIBLE_DEVICES'] = GPU_id
import threading
class Thread(threading.Thread):
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None):
threading.Thread.__init__(self, group, target, name, args, kwargs, daemon=daemon)
self._return = None
def run(self):
if self._target is not None:
self._return = self._target(*self._args, **self._kwargs)
#!/usr/bin/env python
# Copyright (C) 2003-2007 Robey Pointer <[email protected]>
#
# This file is part of paramiko.
#
# Paramiko is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.