This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding:utf-8 | |
''' | |
Created on 2018-05-02 | |
@author: [email protected] | |
@desc: List images name from registry | |
''' | |
from __future__ import print_function | |
import requests | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# author: [email protected] | |
r"""Segment audio or video files to wav. | |
requirements: | |
- http://www.ffmpeg.org/ | |
- pydub | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def freeze_graph(model_dir, output_node_names): | |
"""Extract the sub graph defined by the output nodes and convert | |
all its variables into constant | |
Args: | |
model_dir: the root folder containing the checkpoint state file | |
output_node_names: a string, containing all the output node's names, | |
comma separated | |
""" | |
from os.path import join | |
import tensorflow as tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import os | |
class ExtractFromVideo(object): | |
def __init__(self, path, frame_range=None, debug=False): | |
assert os.path.exists(path) | |
self._p = path | |
self._vc = cv2.VideoCapture(self._p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def describe_graph(graph_def, show_nodes=False): | |
from collections import Counter | |
c = Counter(map(lambda n: n.op, graph_def.node)) | |
print(c) | |
print('Input Nodes: {}'.format([node.name for node in graph_def.node if node.op == 'Placeholder'])) | |
output_nodes = [node.name for node in graph_def.node if ( | |
'predictions' in node.name or 'softmax' in node.name or 'concat' in node.name)] | |
print(f'Output Nodes: {output_nodes}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import os | |
import numpy as np | |
from PIL import Image, ImageFont, ImageDraw | |
from typing import Tuple, Optional, Union, List | |
from dataclasses import dataclass, InitVar | |
import sys | |
from pathlib import Path | |
from enum import Enum | |
import logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import subprocess | |
import shlex | |
import numpy as np | |
def run_process(tmpl, *args, **kwargs): | |
_args = args | |
cmd = tmpl.format(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class TopK(object): | |
def __init__(self, k, key=None, reverse=False) -> None: | |
""" Find k largest or smallest(reverse is True) elements from stream data. | |
""" | |
super(TopK, self).__init__() | |
self._heap = list() | |
self._k = k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tensorflow as tf | |
import numpy as np | |
from PIL import Image | |
import io | |
def bytes_feature(value): | |
"""Returns a bytes_list from a string / byte.""" | |
if isinstance(value, type(tf.constant(0))): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
# @ Author: Lu Liu | |
# @ Create Time: 2024-02-28 18:02:05 | |
# @ Modified by: Lu Liu | |
# @ Modified time: 2024-02-28 18:08:28 | |
# @ Description: | |
''' | |
import time | |