Skip to content

Instantly share code, notes, and snippets.

View Abe404's full-sized avatar
🎯
Focusing

Abraham George Smith Abe404

🎯
Focusing
View GitHub Profile
@mdornseif
mdornseif / zib_datastore.py
Created May 1, 2011 20:44
This is shows how to generate ZIP files in the blobstore.
def store_pdfs_in_zip():
docs = Dokument.all().order('updated_at')
file_name = files.blobstore.create(mime_type='application/zip',
_blobinfo_uploaded_filename='test.zip')
with files.open(file_name, 'w') as f:
z = blobstoreZipFile(f)
for doc in docs.fetch(75):
pdf = doc.data
fname = "%s-%s.pdf" % (doc.designator, doc.updated_at)
fname = fname.encode('ascii', 'replace')
@fmder
fmder / elastic_transform.py
Last active August 22, 2021 14:54
Elastic transformation of an image in Python
import numpy
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@gyglim
gyglim / tensorboard_logging.py
Last active August 23, 2023 21:29
Logging to tensorboard without tensorflow operations. Uses manually generated summaries instead of summary ops
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: BSD License 2.0
"""
__author__ = "Michael Gygli"
import tensorflow as tf
from StringIO import StringIO
import matplotlib.pyplot as plt
import numpy as np
@oeway
oeway / imageUtils.py
Last active May 8, 2024 14:21
Improved image transform functions for dense predictions (for pytorch, keras etc.)
import numpy as np
import scipy
import scipy.ndimage
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.interpolation import map_coordinates
import collections
from PIL import Image
import numbers
__author__ = "Wei OUYANG"