Skip to content

Instantly share code, notes, and snippets.

View numb3r3's full-sized avatar

felix-wang numb3r3

View GitHub Profile
@vict0rsch
vict0rsch / streaming_multilabel_f1_score.py
Last active March 16, 2021 03:17
Streaming and Multilabel F1 score in Tensorflow
# From my blog post: http://vict0rsch.github.io/2018/06/06/tensorflow-streaming-multilabel-f1/
import tensorflow as tf
import numpy as np
from tensorflow.python.ops import variable_scope
from tensorflow.python.ops import array_ops
from tensorflow.python.framework import ops
from sklearn.metrics import f1_score
@echolijinghui
echolijinghui / img_io.py
Created April 3, 2018 09:52
ExpandNet with tensorflow
"""
" Description: TensorFlow ExpandNet for HDR image reconstruction.
" Author: LiJinghui
" Date: March 2018
"""
from __future__ import division
import numpy as np
import cv2
import os, random, glob
import tensorflow as tf
@mangecoeur
mangecoeur / slim_silhouette.py
Created February 16, 2018 13:14
Low memory, good performance implementation of k-means silhouette samples using numba
from sklearn.utils import check_X_y
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics.cluster.unsupervised import check_number_of_labels
from numba import jit
@jit(nogil=True, parallel=True)
def euclidean_distances_numba(X, Y=None, Y_norm_squared=None):
# disable checks
XX_ = (X * X).sum(axis=1)
@t-io
t-io / xvfb_screen_recording.py
Created November 17, 2017 10:34
ScreenRecording xvfb
from selenium import webdriver
import sys, getopt, time, subprocess, shlex
from xvfbwrapper import Xvfb
def run():
print('Sreencast website animation')
xvfb = Xvfb(width=1280, height=720, colordepth=24)
xvfb.start()
@k06a
k06a / install-ffmpeg-with-h265.sh
Last active March 9, 2021 15:51
H265 with ffmpeg
# Installing ffmpeg with H265 support
brew tap varenc/ffmpeg
brew install varenc/ffmpeg/ffmpeg --with-fdk-aac --HEAD
# Installing mp4edit tool
brew install bento4
@damienpontifex
damienpontifex / tf-experiment-template.py
Last active March 9, 2021 09:43
A template for a custom tensorflow estimator and experiment with python3 typings for desired parameter types
import argparse
import psutil
import tensorflow as tf
from typing import Dict, Any, Callable, Tuple
## Data Input Function
def data_input_fn(data_param,
batch_size:int=None,
shuffle=False) -> Callable[[], Tuple]:
"""Return the input function to get the test data.
# Run interactive python tensorflow container
docker run --rm -it --name py-tf --entrypoint python tensorflow/tensorflow:1.3.0-py3
# Run jupyter notebook container
docker run --rm -dit -p 8888:8888 -p 6006:6006 -v "${PWD}":/notebooks --name notebook tensorflow/tensorflow:1.3.0-py3
# Run on ubuntu server with GPU and have it run on startup
nvidia-docker run -dit \
-p 8888:8888 -p 6006:6006 \
-v /home/nbs:/notebooks \
@ilblackdragon
ilblackdragon / seq2seq.py
Last active May 22, 2022 21:42
Example of Seq2Seq with Attention using all the latest APIs
import logging
import numpy as np
import tensorflow as tf
from tensorflow.contrib import layers
GO_TOKEN = 0
END_TOKEN = 1
UNK_TOKEN = 2
@mmellison
mmellison / grpc_asyncio.py
Last active August 6, 2024 01:23
gRPC Servicer with Asyncio (Python 3.6+)
import asyncio
from concurrent import futures
import functools
import inspect
import threading
from grpc import _server
def _loop_mgr(loop: asyncio.AbstractEventLoop):
@hiwonjoon
hiwonjoon / python-ffmpeg.py
Last active November 26, 2023 16:11
ffmpeg and ffprobe subprocess call in python; extract specific frame at some timepoint, extract duration of a video
import subprocess
import datetime
import numpy as np
THREAD_NUM=4
def get_video_info(fileloc) :
command = ['ffprobe',
'-v', 'fatal',
'-show_entries', 'stream=width,height,r_frame_rate,duration',