Skip to content

Instantly share code, notes, and snippets.

View gilbertfrancois's full-sized avatar
💭
Mind awake, body asleep.

Gilbert François gilbertfrancois

💭
Mind awake, body asleep.
View GitHub Profile
@gilbertfrancois
gilbertfrancois / pi_camera.py
Last active November 16, 2022 13:47
Raspberry Pi Camera test with python
import cv2
from picamera import PiCamera
from picamera.array import PiRGBArray
CAMERA_RESOLUTION = (640, 480)
def capture_video():
# Press 'q' to stop the program.
try:
# Setup
@gilbertfrancois
gilbertfrancois / dataframe_apply_multicore.py
Last active March 1, 2022 13:30
Apply a function to a column of a pandas DataFrame with multicore support.
import numpy as np
import pandas as pd
from functools import partial
from multiprocessing import Pool
def apply_multicore(df, n_workers, fn, **kwargs):
"""
Apply a function to a column of a pandas DataFrame, with multicore support.
Parameters
@gilbertfrancois
gilbertfrancois / enc.sh
Last active March 1, 2022 15:15
Shell functions to easily encrypt and decrypt files using AES256-CBC with openssl.
# Add `source enc.sh` to your .bashrc, .profile or .zshrc to include these functions.
#
# For encryption, type:
# $ enc myfile
#
# For decryption, type:
# $ dec myfile.enc
function enc() {
if [ $# -eq 0 ]; then
@gilbertfrancois
gilbertfrancois / bn_test_2.py
Last active July 22, 2020 22:11
MXNet gluon.nn.BatchNorm issue report
import os
import gluoncv
import mxnet as mx
import mxnet.ndarray as nd
import numpy as np
import pandas as pd
from mxnet import init, autograd
from mxnet.gluon import nn
@gilbertfrancois
gilbertfrancois / bn_test.py
Last active July 18, 2020 08:01
MXNet gluon.nn.BatchNorm bug report
# https://discuss.mxnet.io/t/batchnorm-running-var-value-depends-on-context/3401
# https://discuss.mxnet.io/t/hw-9-how-to-prevent-overflow-to-nan/3853
# https://github.com/apache/incubator-mxnet/issues/18100
# https://github.com/apache/incubator-mxnet/issues/18209
# https://github.com/apache/incubator-mxnet/issues/14710
import matplotlib.pyplot as plt
import mxnet as mx
import mxnet.ndarray as nd
@gilbertfrancois
gilbertfrancois / uninstall_gstreamer_macos.sh
Last active February 8, 2024 12:20
Uninstaller for GStreamer on macOS, where GStreamer is installed as framework from the official pkg distribution.
#!/usr/bin/env bash
# Author: Gilbert Francois Duivesteijn
# Date: Febr 2023
# Platform: macOS
# License: Apache
# Discard receipt data for the installed GStreamer packages.
pkgutil --pkgs | grep gstreamer | xargs -I % sudo pkgutil --forget %
# Remove the GStreamer Framework from disk
@gilbertfrancois
gilbertfrancois / build_opencv_macos.sh
Last active January 14, 2019 15:42
Build latest OpenCV for macOS for openFrameworks
#!/usr/bin/env bash
# extract the downloaded opencv-[version].tar.gz to /tmp/opencv-[version], then run this script. The
# package will be installed in /tmp/opencv. If you like it to be installed somewhere else, change the
# INSTALL_PREFIX parameter.
### BEGIN USER SETTINGS
#
OPENCV_SRC=/tmp/opencv-3.4.5
OPENCV_CONTRIB_SRC=/tmp/opencv_contrib-3.4.5/modules
import tensorflow as tf
from google.protobuf import text_format
from tensorflow.python.platform import gfile
def pbtxt_to_graphdef(filename):
with open(filename, 'r') as f:
graph_def = tf.GraphDef()
file_content = f.read()
text_format.Merge(file_content, graph_def)
tf.import_graph_def(graph_def, name='')
@gilbertfrancois
gilbertfrancois / make_tensorflow_cpp_lib_dist.sh
Last active February 11, 2019 10:02
Creates a library distribution with necessary headers and library files that can be used to create Tensorflow C++ programs with your favourite build system, without bazel.
#!/bin/bash
# Creates a dist archive that can be used to create C++ applications with Tensorflow, without bazel
# IMPORTANT: Before running this script, compile tensorflow_cc.so with --config=monolithic, then run this script.
#
# The script is written for Tensorflow v1.11. Update all dependencies in this script when running for a higher version.
# You can find the 3rd party dependency library versions in ${TENSORFLOW_DIR}/tensorflow/workspace.bzl.
#
# Original script: https://github.com/memo/ofxMSATensorFlow/blob/master/scripts/ubuntu/copy_headers.sh
#