This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def _html_repr_helper(contents, index=()): | |
dims_left = contents.ndim - len(index) | |
if dims_left == 0: | |
s = contents[index] | |
else: | |
s = ''.join(_html_repr_helper(contents, index + (i,)) for i in range(contents.shape[len(index)])) | |
return "<div class='numpy-array-ndim-{} numpy-array-ndim-m{}' title='[{}]'>{}</div>".format( |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Built on top of this gist by @karpathy: | |
https://gist.github.com/karpathy/00103b0037c5aaea32fe1da1af553355 | |
stable diffusion dreaming over text prompts | |
creates hypnotic moving videos by smoothly walking randomly through the sample space | |
example way to run this script: | |
$ python stable_diffusion_walk.py --prompts "['blueberry spaghetti', 'strawberry spaghetti']" --seeds 243,523 --name berry_good_spaghetti |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import napari | |
import numpy as np | |
from napari.qt import thread_worker | |
from qtpy.QtWidgets import QPushButton, QVBoxLayout, QWidget | |
# Point property for MALDI points | |
PROPNAME_ACQUIRED = "acquired" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import napari | |
import numpy as np | |
from napari.qt import thread_worker | |
from qtpy.QtWidgets import QPushButton, QVBoxLayout, QWidget | |
PROPNAME_ACQUIRED = "acquired" | |
#def generate_point_grid(nx=500, ny=100, dx=20, dy=20): # starting to lag with current napari master | |
def generate_point_grid(nx=1500, ny=100, dx=20, dy=20): # still working with Martin's branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from shapely.geometry.polygon import Polygon | |
from shapely.geometry import GeometryCollection, LineString | |
def napari_shape_to_shapely(coords: np.ndarray, shape_type: str = "polygon"): | |
""" | |
Convert an individual napari shape from a shapes layer to a shapely object | |
There is no direct correspondence between a 'rectangle' in napari and a 'box' in |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem") | |
c = paramiko.SSHClient() | |
c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
print "connecting" | |
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k ) | |
print "connected" | |
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ] | |
for command in commands: | |
print "Executing {}".format( command ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Volker Hilsenstein | |
# BSD-3 license | |
import numpy as np | |
import skimage.morphology | |
from rotating_calipers import min_max_feret | |
def get_min_max_feret_from_labelim(label_im, labels=None): | |
""" given a label image, calculate the oriented | |
bounding box of each connected component with |
NewerOlder