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 numpy as np | |
import sys | |
import glob | |
import cv2 | |
import time | |
import json | |
import threading | |
import subprocess | |
from queue import Queue |
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 str2bool(v): | |
if isinstance(v, bool): | |
return v | |
if v.lower() in ('yes', 'true', 't', 'y', '1'): | |
return True | |
elif v.lower() in ('no', 'false', 'f', 'n', '0'): | |
return False | |
else: | |
raise argparse.ArgumentTypeError('Boolean value expected.') | |
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 simpler_log(line): | |
global g_log_path | |
if g_log_path != "": | |
with open(g_log_path, 'a', encoding='utf-8') as fout: | |
fout.write(line + "\n") | |
else: | |
g_logger.info("log_path is empty, print guess won't work.") | |
print(line) | |
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 re | |
import json | |
import requests | |
URL = "http://got001.com/resource.html?code=GooBY" | |
API_BASE_URL = "http://got001.com/api/v1/static/resource/detail?code=" | |
re_code = re.compile(r'code=(.*)') |
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
git config --global https.proxy http://127.0.0.1:1080 | |
git config --global https.proxy https://127.0.0.1:1080 | |
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
npm config delete proxy |
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 requests | |
from requests.exceptions import ProxyError, ConnectTimeout, SSLError, ReadTimeout, ConnectionError | |
TEST_URL = "https://www.sogou.com" | |
TEST_TIMEOUT = 30 | |
PROXY_UPDATE_CNT_PER_TIME = 5 | |
PROXY_UPDATE_URL = "https://api-ip.abuyun.com/obtain?license=LC392580C7B8805P&sign=6e696401251f916a510c876df69ff837&cnt=" + str(PROXY_UPDATE_CNT_PER_TIME) | |
def test_proxy(proxy, logger): |
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
# a recursive method that return all combine result of a list | |
def combine(chosen, candidates, to_choose, result): | |
if to_choose == 0: | |
result.add(tuple(chosen)) | |
return | |
else: | |
for i in range(0, len(candidates)-to_choose+1): | |
chosen.append(candidates[i]) | |
combine(chosen, candidates[i+1:len(candidates)], to_choose-1, result) | |
chosen.remove(candidates[i]) |
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 get_logger(from_logger='tensorflow', log_file=None, sh_level=logging.DEBUG, fh_level=logging.DEBUG): | |
"""Create a configured instance of logger.""" | |
fmt = '[%(asctime)s] %(levelname)s : %(message)s' | |
# date_fmt = '%Y-%m-%d %H:%M:%S,uuu' | |
formatter = logging.Formatter(fmt) | |
# get default logger and set lowest logging level | |
logger = logging.getLogger() | |
logger.setLevel(logging.DEBUG) | |
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 load_model(model, input_map=None): | |
"""Loads a tensorflow model and restore the variables to the default session.""" | |
# Check if the model is a model directory (containing a metagraph and a checkpoint file) | |
# or if it is a protobuf file with a frozen graph | |
model_exp = os.path.expanduser(model) | |
if (os.path.isfile(model_exp)): | |
print('Model filename: %s' % model_exp) | |
with tf.gfile.FastGFile(model_exp, 'rb') as f: | |
graph_def = tf.GraphDef() | |
graph_def.ParseFromString(f.read()) |
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
from __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
import os | |
import re | |
import sys | |
import time | |
import json | |
import shutil |