Skip to content

Instantly share code, notes, and snippets.

View dnlcrl's full-sized avatar

dnlcrl

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dnlcrl
dnlcrl / dependabot.yml
Created September 23, 2022 10:32
dependabot.json
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore:"
include: "scope"
import torch
import sys
import os
print("Warning: Do not use this for BatchNorm-using models!")
model_names = sys.argv[1:]
if len(model_names) < 2:
print("need at least two models to average")
#!/usr/bin/env python
import SimpleITK as sitk
import sys, os
if len ( sys.argv ) < 3:
print( "Usage: DicomSeriesReader <input_directory> <output_file>" )
sys.exit ( 1 )
print( "Reading Dicom directory:", sys.argv[1] )
reader = sitk.ImageSeriesReader()
dicom_names = reader.GetGDCMSeriesFileNames( sys.argv[1] )
reader.SetFileNames(dicom_names)
@dnlcrl
dnlcrl / export.py
Last active August 27, 2018 08:14
PyTorch Model Export (Python) Import (Python, C++) Snippets
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(1,1)
def forward(self, x):
y = self.linear(x)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from __future__ import print_function
from PIL import Image
from xtermcolor import colorize
from skimage.exposure import rescale_intensity
import argparse
import numpy as np
import matplotlib.pyplot as plt
import scipy.misc
PIXEL = ' '
for f in `find . -name "fake*.png"`; do convert real_samples.png $f +append $f; done
def bbox(img):
rows = np.any(img, axis=1)
cols = np.any(img, axis=0)
rmin, rmax = np.where(rows)[0][[0, -1]]
cmin, cmax = np.where(cols)[0][[0, -1]]
return slice(rmin, rmax), slice(cmin, cmax)