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
sudo mv /etc/apt/sources.list /etc/apt/sources.list.old | |
sudo echo "# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted | |
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties | |
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted | |
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties | |
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted | |
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties | |
deb http://mirrors.aliyun.com/ubuntu/ xenial universe | |
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe | |
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse |
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
tensorflow::Tensor matToTensor(const cv::Mat &frame){ | |
int height = mat.rows; | |
int width = mat.cols; | |
int depth = mat.channels(); | |
Tensor inputTensor(tensorflow::DT_UINT8, tensorflow::TensorShape({1, height, width, depth})); | |
auto inputTensorMapped = inputTensor.tensor<tensorflow::uint8, 4>(); | |
cv::Mat frame; | |
mat.convertTo(frame, CV_8UC3); | |
const tensorflow::uint8* source_data = (tensorflow::uint8*) frame.data; |
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 numpy as np | |
import random | |
from scipy.stats import norm | |
def generate_parallel_light_mask(mask_size, | |
position=None, | |
direction=None, | |
max_brightness=255, | |
min_brightness=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
import cv2 | |
import numpy as np | |
import random | |
from scipy.stats import norm | |
def generate_spot_light_mask(mask_size, | |
position=None, | |
max_brightness=255, | |
min_brightness=0, | |
mode="gaussian", |
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 urllib.request import urlopen | |
from io import BytesIO | |
from PIL import Image, ImageOps | |
import cv2 | |
def download_and_resize_image(url, filename, new_width=256, new_height=256): | |
response = urlopen(url) | |
image_data = response.read() | |
image_data = BytesIO(image_data) | |
pil_image = Image.open(image_data) |
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 tensorflow as tf | |
import tensorflow_hub as hub | |
import cv2 | |
import numpy as np | |
from scipy.stats import truncnorm | |
# MODULE_PATH = 'https://tfhub.dev/deepmind/biggan-128/2' # 128x128 BigGAN | |
MODULE_PATH = 'https://tfhub.dev/deepmind/biggan-256/2' # 256x256 BigGAN | |
# MODULE_PATH = 'https://tfhub.dev/deepmind/biggan-512/2' # 512x512 BigGAN |
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 | |
from redis import ConnectionPool, Redis | |
import numpy as np | |
import json, time | |
from multithreading import Thread, Event | |
redis_config = {"server": "localhost", | |
"passwd": '', | |
"port": '6379', | |
"db": 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
import tensorflow as tf | |
def load_pb(pb_model): | |
with tf.gfile.GFile(pb_model, "rb") as f: | |
graph_def = tf.GraphDef() | |
graph_def.ParseFromString(f.read()) | |
with tf.Graph().as_default() as graph: | |
tf.import_graph_def(graph_def, name='') | |
return graph |
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 tensorflow as tf | |
from tensorflow.core.framework import types_pb2, graph_pb2, attr_value_pb2 | |
from tensorflow.tools.graph_transforms import TransformGraph | |
from google.protobuf import text_format | |
import numpy as np | |
# object detection api input and output nodes | |
input_name = "image_tensor" | |
output_names = ["detection_boxes", "detection_classes", "detection_scores", "num_detections"] | |
# Const should be float32 in object detection api during nms (see here: https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/non-max-suppression-v4.html) |
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 subprocess as sp | |
import cv2 | |
import numpy as np | |
from PIL import Image | |
import tensorflow as tf | |
ffmpeg_cmd_1 = ["./ffmpeg", "-y", | |
"-hwaccel", "nvdec", | |
"-c:v", "h264_cuvid", | |
"-vsync", "0", |
OlderNewer