Skip to content

Instantly share code, notes, and snippets.

@VolkerH
VolkerH / Volker_Simple_Pandas_Bokeh_minimal.ipynb
Created June 7, 2017 14:03
Jupyter notebook example to demonstrate bokeh error with data frame containing column named field
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@VolkerH
VolkerH / Raster - Streams.ipynb
Created February 20, 2018 14:46
Trying to send image data to a hv.Raster Dynamic map through a pipe
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import numpy as np
import tifffile
import tifffolder
folder = 'C:/Users/Volker/Data/forTalley/'
# u: Tile number in stage X direction
# v: Tile number in stage Y direction
# d: illumination direction (the Ultramicroscopy mileading labels these as channels)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@VolkerH
VolkerH / keras_weighted_binary_crossentropy.py
Created February 9, 2019 14:27 — forked from ksugar/keras_weighted_binary_crossentropy.py
Custom loss function for weighted binary crossentropy in Keras with Tensorflow
# code picked up from https://github.com/keras-team/keras/blob/master/keras/backend/tensorflow_backend.py
# Just used tf.nn.weighted_cross_entropy_with_logits instead of tf.nn.sigmoid_cross_entropy_with_logits with input pos_weight in calculation
import tensorflow as tf
from keras import backend as K
""" Weighted binary crossentropy between an output tensor and a target tensor.
# Arguments
pos_weight: A coefficient to use on the positive examples.
# Returns
@VolkerH
VolkerH / travis_to_conda.md
Created March 28, 2019 05:25 — forked from zshaheen/travis_to_conda.md
How to Setup Automatic Uploads to Anaconda from Travis CI in 15 minutes

How to Setup Automatic Uploads to Anaconda from Travis CI in 15 minutes

TL;DR: Edit .travis.yaml to install Anaconda and to run conda_upload.sh after testing. Edit meta.yaml to take in the environmental variables $VERSION and $CONDA_BLD_PATH. Create conda_upload.sh which sets the needed environmental variables, builds the tar archive, and uploads it to Anaconda. Finally edit some stuff on your Anaconda and Travis CI account so they can talk.

Intro

The following steps will detail how to automatically trigger Anaconda builds and uploads from Travis CI. This will only upload successful builds in the master branch and if there are multiple commits in a single day, it'll only keep the latest one. Both of these settings can easily be changed.

Edit .travis.yaml

First, edit .travis.yml so that it installs Anaconda.

install:
@VolkerH
VolkerH / asciiart.py
Created April 12, 2019 00:09 — forked from wshanshan/asciiart.py
Create ASCII art from an image
from PIL import Image, ImageDraw, ImageFont
from colour import Color
import numpy as np
# The function convert an image to ascii art
# f: Input filename
# SC: the horizontal pixel sampling rate. It should be between 0(exclusive) and 1(inclusive). The larger the number, the more details in the output.
# If you want the ascii art output be the same size as input, use ~ 1/ font size width.
# GCF: >0. It's an image tuning factor. If GCF>1, the image will look brighter; if 0<GCF<1, the image will look darker.
# out_f: output filename
@VolkerH
VolkerH / temperatureCircle.py
Created May 30, 2019 07:08 — forked from anttilipp/temperatureCircle.py
Code to reproduce the "Temperature Circle" visualization.
#
# Hi all,
# this is the Python code I used to make the visualization "Temperature circle"
# (https://twitter.com/anttilip/status/892318734244884480).
# Please be aware that originally I wrote this for my tests only so the
# code was not ment to be published and is a mess and has no comments.
# Feel free to improve, modify, do whatever you want with it. If you decide
# to use the code, make an improved version of it, or it is useful for you
# in some another way I would be happy to know about it. You can contact me
# for example in Twitter (@anttilip). Unchecked demo data (no quarantees)
@VolkerH
VolkerH / runZonalTempViz.py
Created May 30, 2019 07:08 — forked from anttilipp/runZonalTempViz.py
This is the Python code I used to make the visualization # "Temperature anomalies, zonal means, 1900 - 2016"
#
# Hi all,
# this is the Python code I used to make the visualization
# "Temperature anomalies, zonal means, 1900 - 2016"
# (https://twitter.com/anttilip/status/921809347658895361).
# Please be aware that originally I wrote this just to see how this type
# of visualization would work. The code was not ment to be published
# and therefore has only a couple of/no comments and is most likely
# not written in the most optimal way.
#
@VolkerH
VolkerH / run_ilastik.py
Created September 2, 2019 01:49
Proof-of-concept class to run ilastik pixel classifier in headless mode from python (intermediate files are generated as temp files)
# tools to call an external ilastik classifier and run in headless mode
# see
# https://www.ilastik.org/documentation/basics/headless.html
#
# Volker Hilsenstein, Monash Micro Imaging 2019
# License: BSD-3
import subprocess
from abc import ABC, abstractmethod
from typing import List