Skip to content

Instantly share code, notes, and snippets.

View VolkerH's full-sized avatar
🌏
Somewhere at large

Volker Hilsenstein VolkerH

🌏
Somewhere at large
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@VolkerH
VolkerH / napari_browser.py
Created May 29, 2020 04:23 — forked from bioimage-analysis/napari_browser.py
File browser for napari
from PyQt5.QtWidgets import (
QPushButton,
QComboBox,
QTabWidget,
QHBoxLayout,
QFileDialog,
QDialogButtonBox,
QWidget,
QSlider,
)
@VolkerH
VolkerH / main.py
Created November 8, 2019 01:50 — forked from Bomberus/main.py
Asyncqt, concurrent executor example
import sys, asyncio, random, threading, datetime
from qtpy.QtWidgets import QApplication, QProgressBar
from asyncqt import QEventLoop, QThreadExecutor
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
progress = QProgressBar()
@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
@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 / 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 / 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 / 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 / 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.