Skip to content

Instantly share code, notes, and snippets.

View phillies's full-sized avatar

Philipp phillies

View GitHub Profile
@phillies
phillies / nginx.conf
Created June 1, 2019 08:50
nginx reverse proxy config
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@phillies
phillies / Dockerfile
Created June 4, 2019 01:52
Simple docker file for building node development server from git repo
FROM node
RUN git clone https://github.com/phillies/vue_example.git /opt/vue_example
WORKDIR /opt/vue_example
RUN npm install
CMD ["npm", "run", "serve"]
@phillies
phillies / Dockerfile
Created June 4, 2019 03:31
Multi-stage build example for creating a vue app running on nginx web server
FROM node as builder
RUN git clone https://github.com/phillies/vue_example.git /opt/vue_example
WORKDIR /opt/vue_example
RUN npm install && npm run build
FROM nginx
COPY --from=builder /opt/vue_example/dist/ /usr/share/nginx/html/
@phillies
phillies / Dockerfile
Created June 4, 2019 05:36
Multi-stage build with ssh-login to github using deploy keys
FROM node as builder
COPY github_key .
RUN eval $(ssh-agent) && \
ssh-add github_key && \
ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts && \
git clone git@github.com:phillies/vue_example.git /opt/vue_example
WORKDIR /opt/vue_example
RUN npm install && npm run build
@phillies
phillies / unet_extent.py
Created September 19, 2019 05:27
Using a pretrained Unet with any number of input channels
import torch
import segmentation_models_pytorch as smp
in_channels = 8
# load pretrained Unet with resnet34 encoder and imagenet weights
net = smp.Unet()
# Checking the parameters of the first layer
print(net.encoder.conv1)
@phillies
phillies / Dockerfile
Last active December 6, 2019 03:15
jupyterlab-matplotlib issue 154 example docker image
FROM ubuntu:bionic
SHELL ["/bin/bash", "-c"]
RUN apt update -qq && apt upgrade -y -qq
ENV CONDAROOT "/opt/conda"
WORKDIR /root/
ADD https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh /root/
RUN mkdir ~/.conda && \
bash Miniconda3-latest-Linux-x86_64.sh -b -p $CONDAROOT && \
rm -rf Miniconda3-latest-Linux-x86_64.sh && \
@phillies
phillies / tqdm_log.py
Created April 30, 2019 07:00
Using tqdm for status logging
'''This is a toy example on how to use tqdm progress bars to log status messages
in a compact way.
This example reads all .mp4 files from the folder, then iterates through the files
and stores all frames as .png file to another folder.
'''
import os
import imageio
import tqdm
@phillies
phillies / convertRGB.kt
Created June 29, 2020 14:01
Convert FloatArray coming from pytorch Tensor to Bitmap
fun floatArrayToColorBitmap (
floatArray: FloatArray,
width: Int,
height: Int,
alpha :Byte = (255).toByte(),
reverseScale :Boolean = false
) : Bitmap {
// Create empty bitmap in RGBA format (even though it says ARGB but channels are RGBA)
val bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
@phillies
phillies / Dockerfile
Last active August 9, 2020 16:21
Reproducibility-oriented docker with pytorch and cuda support
FROM nvidia/cuda:10.1-base
# install git for accessing repositories
# and make /opt accessible for all users
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
chmod 777 /opt
SHELL ["/bin/bash", "-c"]
@phillies
phillies / example.py
Last active January 16, 2023 15:11
Example for MLFlow creating warnings when storing pytorch models
from torch import nn
import logging
import mlflow
import torch
class MLP(nn.Module):
def __init__(self):
super().__init__()
self.layers = nn.Sequential(
nn.Linear(633, 1024),