code
stringlengths
17
6.64M
def init_devices(device_type=None): if (device_type is None): device_type = 'cpu' num_cores = 4 if (device_type == 'gpu'): num_GPU = 1 num_CPU = 1 else: num_CPU = 1 num_GPU = 0 config = tf.ConfigProto(intra_op_parallelism_threads=num_cores, inter_op_parallel...
def reporthook(block_num, block_size, total_size): read_so_far = (block_num * block_size) if (total_size > 0): percent = ((read_so_far * 100.0) / total_size) s = ('\r%5.1f%% %*d / %d' % (percent, len(str(total_size)), read_so_far, total_size)) sys.stderr.write(s) if (read_so_fa...
def download_glove(data_dir_path=None): if (data_dir_path is None): data_dir_path = 'very_large_data' glove_model_path = (((data_dir_path + '/glove.6B.') + str(GLOVE_EMBEDDING_SIZE)) + 'd.txt') if (not os.path.exists(glove_model_path)): glove_zip = (data_dir_path + '/glove.6B.zip') ...
def load_glove(data_dir_path=None): if (data_dir_path is None): data_dir_path = 'very_large_data' download_glove(data_dir_path) _word2em = {} glove_model_path = (((data_dir_path + '/glove.6B.') + str(GLOVE_EMBEDDING_SIZE)) + 'd.txt') file = open(glove_model_path, mode='rt', encoding='utf8'...
def glove_zero_emb(): return np.zeros(shape=GLOVE_EMBEDDING_SIZE)
class Glove(object): word2em = None GLOVE_EMBEDDING_SIZE = GLOVE_EMBEDDING_SIZE def __init__(self): self.word2em = load_glove()
def in_white_list(_word): for char in _word: if (char in WHITELIST): return True return False
def absTokenizer1(regex, abstracts): '\n above abstractTokenizer returns all the word but sentence structured.\n ' stopWords = set(stopwords.words('english')) tokenizer = RegexpTokenizer(regex) tokened = [tokenizer.tokenize(abstract) for abstract in abstracts] print('Abstracts are tokenized....
def df2model(path_to_json): data = json2list(path_to_json) df_to_model = pd.DataFrame({'Abstracts': absTokenizer1('\\w+', data['abstracts']), 'Titles': data['titles']}) df_to_model.columns = ['input_text', 'target_text'] for i in range(len(df_to_model)): df_to_model.iloc[(i, 0)] = ' '.join(df_...
def fit_text(X, Y, input_seq_max_length=None, target_seq_max_length=None): if (input_seq_max_length is None): input_seq_max_length = MAX_INPUT_SEQ_LENGTH if (target_seq_max_length is None): target_seq_max_length = MAX_TARGET_SEQ_LENGTH input_counter = Counter() target_counter = Counter...
def getCategoryVocab(df_raw): df_raw = pd.read_csv(df_raw) category_vocab = [item for sublist in (category.split(' ') for category in df_raw['Category']) for item in sublist] return category_vocab
def getCategoryVocabByYear(df_raw): df_raw = pd.read_csv(df_raw) category_year_vocab = [] pair = [] for i in range(len(df_raw)): splitted = df_raw.iloc[(i, (- 1))].split(' ') for splits in splitted: pair.append(splits) pair.append(df_raw.iloc[(i, (- 2))]) ...
def countCategoryVocabByYear(category_vocab_by_year): count = collections.defaultdict(dict) i = 0 for pair in category_vocab_by_year: try: count[str(pair[1])][pair[0]] = 0 except Exception as e: if (e is IndexError): print('This exception is not poss...
def countCategories(category_vocab, k): countCat = collections.defaultdict(int) for cat in category_vocab: countCat[cat] += 1 return dict(islice(collections.OrderedDict(countCat).items(), k))
def populars(df_csv_raw, k=10): df_raw = pd.read_csv(df_csv_raw) category_vocab = getCategoryVocab(df_csv_raw) topk = countCategories(category_vocab, 10) print('TOP 10 CATEGORY BY POPULARITY') for (key, value) in topk.items(): print(' {}: {}'.format(key, value))
def popularsbar(df_csv_raw, k): df_raw = pd.read_csv(df_csv_raw) category_vocab = getCategoryVocab(df_csv_raw) topk = countCategories(category_vocab, k) cat_dir = '../data/categories.json' with open(cat_dir) as json_file: categories = json.load(json_file) legends = [] for a in list...
def get(seed=0, pc_valid=0.1): data = {} taskcla = [] size = [3, 32, 32] if (not os.path.isdir(file_dir)): os.makedirs(file_dir) mean = [(x / 255) for x in [125.3, 123.0, 113.9]] std = [(x / 255) for x in [63.0, 62.1, 66.7]] dat = {} dat['train'] = datasets.CIFA...
def cifar100_superclass_python(task_order, group=5, validation=False, val_ratio=0.05, flat=False, one_hot=True, seed=0): CIFAR100_LABELS_LIST = ['apple', 'aquarium_fish', 'baby', 'bear', 'beaver', 'bed', 'bee', 'beetle', 'bicycle', 'bottle', 'bowl', 'boy', 'bridge', 'bus', 'butterfly', 'camel', 'can', 'castle', '...
def imshow(img): npimg = img plt.imshow(np.transpose(npimg, (1, 2, 0))) plt.show()
def get(seed=1, fixed_order=False, pc_valid=0.05): data = {} taskcla = [] size = [3, 32, 32] idata = np.arange(5) print('Task order =', idata) if (not os.path.isdir('./data/Five_data/binary_mixture_5_Data/')): os.makedirs('./data/Five_data/binary_mixture_5_Data') for (n, idx) i...
class FashionMNIST(datasets.MNIST): '`Fashion MNIST <https://github.com/zalandoresearch/fashion-mnist>`_ Dataset.\n ' urls = ['http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz', 'http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz', 'ht...
class TrafficSigns(torch.utils.data.Dataset): "`German Traffic Signs <http://benchmark.ini.rub.de/?section=gtsrb&subsection=dataset>`_ Dataset.\n\n Args:\n root (string): Root directory of dataset where directory ``Traffic signs`` exists.\n split (string): One of {'train', 'test'}.\n trans...
class Facescrub(torch.utils.data.Dataset): "Subset of the Facescrub cropped from the official Megaface challenge page: http://megaface.cs.washington.edu/participate/challenge.html, resized to 38x38\n\n Args:\n root (string): Root directory of dataset where directory ``Traffic signs`` exists.\n sp...
class notMNIST(torch.utils.data.Dataset): "The notMNIST dataset is a image recognition dataset of font glypyhs for the letters A through J useful with simple neural networks. It is quite similar to the classic MNIST dataset of handwritten digits 0 through 9.\n\n Args:\n root (string): Root directory of ...
def get(seed=0, fixed_order=False, pc_valid=0.1): data = {} taskcla = [] size = [1, 28, 28] nperm = 10 seeds = np.array(list(range(nperm)), dtype=int) if (not fixed_order): seeds = shuffle(seeds, random_state=seed) if (not os.path.isdir(pmnist_dir)): os.makedirs(pmnist_dir)...
class LanguageIdentification(object): def __init__(self, language): self.language = language if (self.language == 'spa-eng'): print('Downloading pretrained model. It will take time according to model size and your internet speed') self.tokenizer = AutoTokenizer.from_pretra...
class POS(object): def __init__(self, language): self.language = language if (self.language == 'spa-eng'): print('Downloading pretrained model. It will take time according to model size and your internet speed') self.tokenizer = AutoTokenizer.from_pretrained('sagorsarker/c...
class NER(object): def __init__(self, language): self.language = language if (self.language == 'spa-eng'): print('Downloading pretrained model. It will take time according to model size and your internet speed') self.tokenizer = AutoTokenizer.from_pretrained('sagorsarker/c...
class SentimentAnalysis(object): def __init__(self, language): if (language == 'spa-eng'): self.tokenizer = AutoTokenizer.from_pretrained('sagorsarker/codeswitch-spaeng-sentiment-analysis-lince') self.model = AutoModelForSequenceClassification.from_pretrained('sagorsarker/codeswit...
class Config(object): 'Base configuration class. For custom configurations, create a\n sub-class that inherits from this one and override properties\n that need to be changed.\n ' NAME = None GPU_COUNT = 1 IMAGES_PER_GPU = 1 STEPS_PER_EPOCH = 1000 VALIDATION_STEPS = 10 BACKBONE = ...
class ParallelModel(KM.Model): 'Subclasses the standard Keras Model and adds multi-GPU support.\n It works by creating a copy of the model on each GPU. Then it slices\n the inputs and sends a slice to each copy of the model, and then\n merges the outputs together and applies the loss on the combined\n ...
class Config(object): 'Base configuration class. For custom configurations, create a\n sub-class that inherits from this one and override properties\n that need to be changed.\n ' NAME = None GPU_COUNT = 1 IMAGES_PER_GPU = 1 STEPS_PER_EPOCH = 500 VALIDATION_STEPS = 10 BACKBONE = '...
class ParallelModel(KM.Model): 'Subclasses the standard Keras Model and adds multi-GPU support.\n It works by creating a copy of the model on each GPU. Then it slices\n the inputs and sends a slice to each copy of the model, and then\n merges the outputs together and applies the loss on the combined\n ...
def _parse_requirements(file_path): pip_ver = pkg_resources.get_distribution('pip').version pip_version = list(map(int, pip_ver.split('.')[:2])) if (pip_version >= [6, 0]): raw = pip.req.parse_requirements(file_path, session=pip.download.PipSession()) else: raw = pip.req.parse_requirem...
def create_root(file_prefix, width, height, depth): root = ET.Element('annotations') ET.SubElement(root, 'folder').text = 'images' ET.SubElement(root, 'filename').text = '{}'.format(file_prefix) ET.SubElement(root, 'path').text = (output_images_dir + '{}'.format(file_prefix)) source = ET.SubElemen...
def create_object_annotation(root, table_list, table_information_list): length_table_list = len(table_list) print('length_table_list==>', length_table_list) for i in range(length_table_list): obj = ET.SubElement(root, 'object') ET.SubElement(obj, 'name').text = 'table' ET.SubElemen...
def match_ann(fileName): js = json.loads(open(fileName).read()) for items in js['people']: handRight = items['hand_right_keypoints_2d'] confPoints = helper.confidencePoints(handRight) confidence = helper.confidence(confPoints) if (confidence > 10.2): handPoints = helper.removePoint...
def signal_handler(signal, frame): shutil.rmtree('Keypoints', ignore_errors=True, onerror=handleRemoveReadonly) shutil.rmtree('gui\\captured_images', ignore_errors=True, onerror=handleRemoveReadonly) shutil.rmtree('gui\\temp_images', ignore_errors=True, onerror=handleRemoveReadonly) print('All done') ...
def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if ((func in (os.rmdir, os.remove)) and (excvalue.errno == errno.EACCES)): os.chmod(path, ((stat.S_IRWXU | stat.S_IRWXG) | stat.S_IRWXO)) func(path) else: raise Exception
def plotPose(posePoints, handRightPoints, handLeftPoints): POSE_PAIRS = [[1, 0], [1, 2], [1, 5], [2, 3], [3, 4], [5, 6], [6, 7], [1, 8], [0, 15], [15, 17], [0, 16], [16, 18]] HAND_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [...
@eel.expose def capture_alphabet_dataset(sec): global remfileNames '\n ----------------------Start OpenPoseDemo.exe----------------------\n --render_pose 0 --display 0\n ' os.chdir('bin\\openpose') print('Starting OpenPose') subprocess.Popen('bin\\OpenPoseDemo.exe --hand --write_json .....
@eel.expose def getFileCount(): Names = [] for entry in os.scandir('gui\\captured_images'): Names.append(entry.name) return str(len(Names))
@eel.expose def delete_Image(i): global remfileNames print(remfileNames) try: os.remove(('Keypoints\\' + remfileNames[(i - 1)])) os.remove((('gui\\captured_images\\' + str(i)) + '.jpg')) except: print('file not found') pass
@eel.expose def getlabel(a): label = a.strip() print(label) "\n traverse 'dataset' folder ,\n find subfolder matching 'label' ,\n create folder with timestamp in matched folder , \n and copy everything from 'Keypoints_temp' to created folder\n " for entry in os.scandir('data\\datasets\...
@eel.expose def db_train(): retrain.re_train(1)
def signal_handler(signal, frame): shutil.rmtree('Keypoints', ignore_errors=True, onerror=handleRemoveReadonly) print('All done') sys.exit(0)
def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if ((func in (os.rmdir, os.remove)) and (excvalue.errno == errno.EACCES)): os.chmod(path, ((stat.S_IRWXU | stat.S_IRWXG) | stat.S_IRWXO)) func(path) else: raise Exception
def json_files(Dir): folders = [] files = [] fileNames = [] for entry in os.scandir(Dir): if entry.is_dir(): folders.append(entry.path) for entry1 in os.scandir(entry.path): if entry1.is_dir(): folders.append(entry1.path) ...
def removePoints(handRight): handRightResults = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 3): handRightX.append(handRight[x]) for x in range(1, len(handRight), 3): handRightY.append(handRight[x]) for x in range(len(handRightX)): handRightResul...
def getCoordPoints(handRight): handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 3): handRightX.append(handRight[x]) for x in range(1, len(handRight), 3): handRightY.append(handRight[x]) for x in range(len(handRightX)): handRightPoin...
def confidencePoints(handRight): handRightC = [] for x in range(2, len(handRight), 3): handRightC.append(handRight[x]) return handRightC
def confidence(handRight): sum = handRight[0] for x in range(1, len(handRight)): sum += handRight[x] return sum
def seperate_points(handRight): handRightResults = [] handRightX = [] handRightY = [] for x in range(len(handRight)): handRightX.append(handRight[x][0]) handRightY.append(handRight[x][1]) for x in range(len(handRight)): handRightResults.append(handRightX[x]) handRig...
def join_points(handRight): handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) for x in range(len(handRightX)): handRightPoints....
def isolatePoints(handRight): handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) minX = min(handRightX, key=fl...
def centerPoints(handRight): refX = 150 refY = 150 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) ...
def dummy_centerPoints(handRight): refX = 600 refY = 600 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]...
def movePoints(handRight, addX, addY): refX = (handRight[0] + addX) refY = (handRight[1] + addY) handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2)...
def moveBothHands(handRight, handLeft, addX, addY): refX = (handRight[0] + addX) refY = (handRight[1] + addY) handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(h...
def move_to_wrist(handRight, wristX, wristY): refX = wristX refY = wristY handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.ap...
def scaleBody(handRight, distance): ref = 200 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) scale = (...
def moveBody(handRight): refX = 1000 refY = 400 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) p1 ...
def dummyMoveBody(handRight): refX = 400 refY = 200 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) ...
def dummyScaleBody(handRight, distance): ref = 500 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) scal...
def plot_skeleton(fileName, background, isMove, isScale): js = json.loads(open(fileName).read()) for items in js['people']: handRight = items['hand_right_keypoints_2d'] handCoord = helper.getCoordPoints(handRight) handPoints = helper.removePoints(handRight) p1 = [handPoints[0], handPoints[...
def plot_points(points, background): handRight = points handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) for x in range(len(handRi...
def plot_db(): ret_frame = [] POSE_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] background = 'big_background.png' connection = sqlite3.connect('db\\main_datase...
def plot_db_label(label): ret_frame = [] POSE_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] background = 'big_background.png' connection = sqlite3.connect('db\\...
def plot_dataset(handRightPoints, color): ret_frame = [] POSE_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] colors = [[0, 0, 130], [0, 0, 175], [0, 0, 210], [0, 0, ...
def save_old_dataset(handRightPoints, color, name): POSE_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] colors = [[0, 0, 130], [0, 0, 175], [0, 0, 210], [0, 0, 250], [0,...
def plotPose(posePoints, handRightPoints, handLeftPoints): POSE_PAIRS = [[1, 0], [1, 2], [1, 5], [2, 3], [3, 4], [5, 6], [6, 7], [1, 8], [0, 15], [15, 17], [0, 16], [16, 18]] HAND_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [...
def plotPoseDataset(): POSE_PAIRS = [[1, 0], [1, 2], [1, 5], [2, 3], [3, 4], [5, 6], [6, 7], [1, 8], [0, 9], [9, 11], [0, 10], [10, 12]] HAND_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], ...
def rotate(point, angle, center_point=(0, 0)): 'Rotates a point around center_point(origin by default)\n Angle is in degrees.\n Rotation is counter-clockwise\n ' angle_rad = radians((angle % 360)) new_point = ((point[0] - center_point[0]), (point[1] - center_point[1])) new_point = (((new_poin...
def rotate_file(fileName): js = json.loads(open(fileName).read()) for items in js['people']: handRight = items['hand_right_keypoints_2d'] handPoints = helper.removePoints(handRight) p1 = [handPoints[0], handPoints[1]] p2 = [handPoints[18], handPoints[19]] distance = math.sqrt((((p1[0] ...
def rotate_points(points, angle): coordPoints = helper.join_points(points) newPoints = [coordPoints[0]] for x in range(1, len(coordPoints)): newPoints.append(rotate(coordPoints[x], angle, coordPoints[0])) return newPoints
def rotate_line(origin, point, angle): '\n Rotate a point counterclockwise by a given angle around a given origin.\n\n The angle should be given in radians.\n ' (ox, oy) = origin (px, py) = point qx = ((ox + (math.cos(angle) * (px - ox))) - (math.sin(angle) * (py - oy))) qy = ((oy + (math...
def scalePoints(handRight, distance): ref = 50 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) scale = ...
def dummy_scalePoints(handRight, distance): ref = 200 handRightResults = [] handRightPoints = [] handRightX = [] handRightY = [] for x in range(0, len(handRight), 2): handRightX.append(handRight[x]) for x in range(1, len(handRight), 2): handRightY.append(handRight[x]) s...
def synthesize(angle): '\n extracting data from db\n ' connection = sqlite3.connect('data\\db\\main_dataset.db') crsr = connection.cursor() sql = 'SELECT x1,y1' for x in range(2, 22): sql = ((((sql + ',x') + str(x)) + ',y') + str(x)) sql = (sql + ' FROM rightHandDataset WHERE 1')...
def synthesize_multiple(angle1, angle2): '\n extracting data from db\n ' connection = sqlite3.connect('..\\..\\data\\db\\main_dataset.db') crsr = connection.cursor() sql = 'SELECT x1,y1' for x in range(2, 22): sql = ((((sql + ',x') + str(x)) + ',y') + str(x)) sql = (sql + ' FROM ...
def re_train(mode): if (mode == 0): dbh.create_table() dbh.populate_db() synth.synthesize(20) alphabet_model.train_alphabets() if (mode == 1): dbh.create_pose_table() dbh.populate_words() word_model.train_words()
def match_ann(fileName): js = json.loads(open(fileName).read()) for items in js['people']: pose = items['pose_keypoints_2d'] handRight = items['hand_right_keypoints_2d'] handLeft = items['hand_left_keypoints_2d'] RightConfPoints = helper.confidencePoints(handRight) LeftConfPoin...
def signal_handler(signal, frame): shutil.rmtree('Keypoints', ignore_errors=True, onerror=handleRemoveReadonly) shutil.rmtree('gui\\Learn_images', ignore_errors=True, onerror=handleRemoveReadonly) os.system('taskkill /f /im OpenPoseDemo.exe') print('All done') sys.exit(0)
def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if ((func in (os.rmdir, os.remove)) and (excvalue.errno == errno.EACCES)): os.chmod(path, ((stat.S_IRWXU | stat.S_IRWXG) | stat.S_IRWXO)) func(path) else: raise Exception
@eel.expose def skip_Sign(): global skip_sign skip_sign = True print('skip_sign')
@eel.expose def openposelearn(): '\n Starting OpenPoseDemo.exe\n and storing json files to temporary folder [Keypoints]\n ' print('Starting OpenPose') os.chdir('bin\\openpose') subprocess.Popen('bin\\OpenPoseDemo.exe --hand --write_json ..\\..\\Keypoints --net_resolution 128x128 --number_p...
def plotPose(posePoints, handRightPoints, handLeftPoints): POSE_PAIRS = [[1, 0], [1, 2], [1, 5], [2, 3], [3, 4], [5, 6], [6, 7], [1, 8], [0, 15], [15, 17], [0, 16], [16, 18]] HAND_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [...
@eel.expose def learning(): global skip_sign '\n storing json files to temporary folder [Keypoints]\n Creating temp folder and initializing with zero padded json file\n ' dirName = 'Keypoints' fileName = 'PSL\\000000000000_keypoints.json' try: os.mkdir(dirName) shutil.copy...
def on_close(page, sockets): print(page, 'closed') print('Still have sockets open to', sockets)
def signal_handler(signal, frame): shutil.rmtree('Keypoints', ignore_errors=True, onerror=handleRemoveReadonly) os.system('taskkill /f /im OpenPoseDemo.exe') print('All done') sys.exit(0)
def handleRemoveReadonly(func, path, exc): excvalue = exc[1] if ((func in (os.rmdir, os.remove)) and (excvalue.errno == errno.EACCES)): os.chmod(path, ((stat.S_IRWXU | stat.S_IRWXG) | stat.S_IRWXO)) func(path) else: raise Exception
def plotPose(posePoints, handRightPoints, handLeftPoints): POSE_PAIRS = [[1, 0], [1, 2], [1, 5], [2, 3], [3, 4], [5, 6], [6, 7], [1, 8], [0, 15], [15, 17], [0, 16], [16, 18]] HAND_PAIRS = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [...
@eel.expose def exit_openpose(): os.system('taskkill /f /im OpenPoseDemo.exe')
@eel.expose def openpose(): '\n Starting OpenPoseDemo.exe\n and storing json files to temporary folder [Keypoints]\n ' print('Starting OpenPose') os.chdir('bin\\openpose') subprocess.Popen('bin\\OpenPoseDemo.exe --hand --write_json ..\\..\\Keypoints --net_resolution 128x128 --number_people...
@eel.expose def match(speech, mode): global label, lastLabel '\n Load each .json file from Keypoints folder and\n predict the label\n ' for entry in os.scandir('Keypoints'): if entry.is_file(): if (os.path.splitext(entry)[1] == '.json'): filePlotName = entry.na...
def test_file1_method1(): x = 5 y = 6 assert ((x + 1) == y), 'test failed' assert (x == y), 'test failed'
def test_file1_method2(): x = 5 y = 6 assert ((x + 1) == y), 'test failed'
def call_html(): import IPython display(IPython.core.display.HTML('\n <script src="/static/components/requirejs/require.js"></script>\n <script>\n requirejs.config({\n paths: {\n base: \'/static/base\',\n "d3": "https://cdnjs.cloudflare.com/ajax/libs...
def call_html(): import IPython display(IPython.core.display.HTML('\n <script src="/static/components/requirejs/require.js"></script>\n <script>\n requirejs.config({\n paths: {\n base: \'/static/base\',\n "d3": "https://cdnjs.cloudflare.com/ajax/libs...
def branch2num(branch, init_root=0): num = [init_root] for b in branch: if (b == 'L'): num.append(((num[(- 1)] * 2) + 1)) if (b == 'R'): num.append(((num[(- 1)] * 2) + 2)) return num