Skip to content

Instantly share code, notes, and snippets.

View pangyuteng's full-sized avatar

pangyuteng

View GitHub Profile
@pangyuteng
pangyuteng / keras_spatial_bias.py
Last active November 13, 2019 19:09 — forked from N-McA/keras_spatial_bias.py
Concatenates the (x, y) coordinate normalised to 0-1 to each spatial location in the image. Allows a network to learn spatial bias. Has been explored in at least one paper, "An Intriguing Failing of Convolutional Neural Networks and the CoordConv Solution" https://arxiv.org/abs/1807.03247
class ConcatSpatialCoordinate(Layer):
def __init__(self, **kwargs):
"""Concatenates the (x, y) coordinate normalised to 0-1 to each spatial location in the image.
Allows a network to learn spatial bias. Has been explored in at least one paper,
"An Intriguing Failing of Convolutional Neural Networks and the CoordConv Solution"
https://arxiv.org/abs/1807.03247
Improves performance where spatial bias is appropriate.
Works with dynamic shapes.
@pangyuteng
pangyuteng / ssh-airplane-wifi.md
Last active October 20, 2019 18:12 — forked from guillochon/ssh-airplane-wifi.md
Instructions on how to SSH on airplane WiFi that blocks port 22

Using SSH through airplane WiFi that blocks port 22 (via GCP and Ubuntu)

SUMMARY

Open WIFI often allow only traffic via http and https ports. This gist contains steps to allow you to ssh to a machine by first creating a VM, switching the ssh port to listen to port 80. So now, you can ssh (port 80) into the VM, in order to ssh (port 22) into your desired machine.

original gist by guillochon, this Fork contains reformatted steps, and I switched OS from CentOs to Ubuntu... just as an exercise to get famaliarized with GCP.

https://gist.github.com/guillochon/eeaa54b328952d260472c14c559f698a

Estimated time to complete the below steps is 5 to 10 minutes (assuming the internet connection is good, and GCP is operating smoothly).
@pangyuteng
pangyuteng / CMakeLists.txt
Last active November 1, 2024 08:42
Sample code to build a cython module via Scikit Build; Dockfile also contains instructions for building ITK VTK Boost (with Python 3.7 via Conda) Zlib with CMake in Ubuntu.
cmake_minimum_required(VERSION 3.5)
project(_hello)
# Find python and Boost - both are required dependencies
find_package(PythonLibs REQUIRED)
find_package(PythonInterp REQUIRED)
find_package(PythonExtensions REQUIRED)
find_package(Cython REQUIRED)
find_package(ZLIB REQUIRED)
@pangyuteng
pangyuteng / CMakeLists.txt
Last active July 12, 2019 21:30 — forked from ndevenish/CMakeLists.txt
Very simple "Getting started" boost-python CMakeLists.txt - added Dockerfile
cmake_minimum_required(VERSION 3.5)
# Find python and Boost - both are required dependencies
find_package(PythonLibs 2.7 REQUIRED)
find_package(Boost COMPONENTS python REQUIRED)
# Without this, any build libraries automatically have names "lib{x}.so"
set(CMAKE_SHARED_MODULE_PREFIX "")
# Add a shared module - modules are intended to be imported at runtime.
@pangyuteng
pangyuteng / jinja2_file_less.py
Created June 25, 2019 16:26 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@pangyuteng
pangyuteng / Dockerfile
Last active September 25, 2024 16:52
docker miniconda ubuntu
#
# ref https://github.com/tebeka/pythonwise/blob/master/docker-miniconda/Dockerfile
#
# miniconda vers: http://repo.continuum.io/miniconda
# sample variations:
# Miniconda3-latest-Linux-armv7l.sh
# Miniconda3-latest-Linux-x86_64.sh
# Miniconda3-py38_4.10.3-Linux-x86_64.sh
# Miniconda3-py37_4.10.3-Linux-x86_64.sh
#
@pangyuteng
pangyuteng / readme.md
Created May 21, 2019 04:09
cvat share - via mount

use the share option in CVAT per davidblom cvat-ai/cvat#203

update CVAT docker-compose.yml to follow the below, where /home/david/shared_data is the local share.

version: "2.3"

services:
  cvat:
 volumes:
@pangyuteng
pangyuteng / data-source-abstraction-layer.md
Last active October 23, 2019 05:29
work-in-progress data source abstraction architecture/design pattern

work-in-progress data source abstraction architecture/design pattern

#### Data source abtraction layer

class FileStore
    def write
    def read
    def remove
@pangyuteng
pangyuteng / README.md
Last active October 3, 2024 16:46
triggering of http dag jobs with asyncio and aiohttp

Sample code to run DAG jobs with python asyncio and aiohttp libraries.

example DAG

    D______
A _/  C    \
   \_/ \_E__\_F
     \ /

B

@pangyuteng
pangyuteng / test_tfrecords.py
Last active January 22, 2019 05:16
profiling loading of multiple tfrecords versus one tfrecords
import sys,os
import tensorflow as tf
import numpy as np
from tensorflow.python.estimator.model_fn import ModeKeys as Modes
tf.logging.set_verbosity(tf.logging.INFO)
w = 512
h = 512
d = 300
c = 11