Skip to content

Instantly share code, notes, and snippets.

@ksamuel
ksamuel / feeds.py
Created October 24, 2011 00:39
RSS/Atom link auto detection. Use feedparser and beautifulsoup
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4
"""
Tools to extract feed links, test if they are valid and parse them
with feedparser, returning content or a proper error.
"""
@kastnerkyle
kastnerkyle / conv_deconv_vae.py
Last active October 19, 2024 08:20
Convolutional Variational Autoencoder, modified from Alec Radford at (https://gist.github.com/Newmu/a56d5446416f5ad2bbac)
# Alec Radford, Indico, Kyle Kastner
# License: MIT
"""
Convolutional VAE in a single file.
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu)
Additionally converted to use default conv2d interface instead of explicit cuDNN
"""
import theano
import theano.tensor as T
from theano.compat.python2x import OrderedDict
@tabacof
tabacof / vae_mlp.py
Last active October 20, 2022 01:04
Variational Auto-Encoder (MLP encoder/decoder)
# -*- coding: utf-8 -*-
"""
Reproducing the results of Auto-Encoding Variational Bayes by Kingma and Welling
With a little help from the code from van Amersfoort and Otto Fabius (https://github.com/y0ast)
@author: Pedro Tabacof (tabacof at gmail dot com)
"""
import random
import numpy as np
@elad
elad / neural-style-ec2.txt
Created September 7, 2015 08:09
Running neural-style in EC2
Start a g2.2xlarge or better (GPU instance) with https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-ffba7b94
Login, username is ubuntu
Update a bunch of stuff and make sure cudnn R2 is used:
luarocks install image
luarocks install loadcaffe
luarocks install torch
export LD_LIBRARY_PATH=/home/ubuntu/torch-distro/install/lib:/home/ubuntu/torch-distro/install/lib:/home/ubuntu/cudnn-6.5-linux-x64-v2-rc2
@genekogan
genekogan / _Instructions.md
Last active September 21, 2024 10:33
instructions for generating a style transfer animation from a video

Instructions for making a Neural-Style movie

The following instructions are for creating your own animations using the style transfer technique described by Gatys, Ecker, and Bethge, and implemented by Justin Johnson. To see an example of such an animation, see this video of Alice in Wonderland re-styled by 17 paintings.

Setting up the environment

The easiest way to set up the environment is to simply load Samim's a pre-built Terminal.com snap or use another cloud service like Amazon EC2. Unfortunately the g2.2xlarge GPU instances cost $0.99 per hour, and depending on parameters selected, it may take 10-15 minutes to produce a 512px-wide image, so it can cost $2-3 to generate 1 sec of video at 12fps.

If you do load the

@gordonbrander
gordonbrander / hollywood-supply-chain.md
Last active January 13, 2016 10:45
Hollywood supply chain

In one Critical Path episode (can't remember which), Horace posits that Hollywood is like a distributed functional organization:

  • Workers are organized by specialty (acting,
@kastnerkyle
kastnerkyle / markov_lm.py
Last active June 15, 2016 17:15
A simple and effective markov language model of configurable temperature and order
# A reduction of the post by Yoav Goldberg to a script
# https://gist.github.com/yoavg/d76121dfde2618422139
# Author: Kyle Kastner
# License: BSD 3-Clause
# Fun alternate settings
# Download kjv.txt from http://www.ccel.org/ccel/bible/kjv.txt
# python markov_lm.py kjv.txt 5 1.
# Snippet:
# Queen ording found Raguel: I kill.
@dannguyen
dannguyen / README.openai-structured-output-demo.md
Last active January 3, 2025 19:55
A basic test of OpenAI's Structured Output feature against financial disclosure reports and a newspaper's police blotter. Code examples use the Python SDK and pydantic for the schema definition.

Extracting financial disclosure reports and police blotter narratives using OpenAI's Structured Output

tl;dr this demo shows how to call OpenAI's gpt-4o-mini model, provide it with URL of a screenshot of a document, and extract data that follows a schema you define. The results are pretty solid even with little effort in defining the data — and no effort doing data prep. OpenAI's API could be a cost-efficient tool for large scale data gathering projects involving public documents.

OpenAI announced Structured Outputs for its API, a feature that allows users to specify the fields and schema of extracted data, and guarantees that the JSON output will follow that specification.

For example, given a Congressional financial disclosure report, with assets defined in a table like this: