Skip to content

Instantly share code, notes, and snippets.

View LiamHz's full-sized avatar

Liam Hinzman LiamHz

View GitHub Profile
# Get the "features" portion of VGG19
# The classifier portion is not needed for style transfer
vgg = models.vgg19(pretrained=True).features
# Freeze all VGG parameters
# Since only activations are measured for each conv layer
# Network weights aren't modified
for param in vgg.parameters():
param.requires_grad_(False)
from __future__ import division
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import cv2
def predict_transform(prediction, inp_dim, anchors, num_classes, CUDA = True):
class DQN(nn.Module):
def __init__(self, input_shape, n_actions):
super(DQN, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(input_shape[0], 32, kernel_size=8, stride=4),
nn.ReLU(),
nn.Conv2d(32, 64, kernel_size=4, stride=2),
nn.ReLU(),
nn.Conv2d(64, 64, kernel_size=3, stride=1),
from google.colab.output import eval_js
from base64 import b64decode
VIDEO_HTML = """
<video autoplay
width=800 height=600></video>
<script>
var video = document.querySelector('video')
navigator.mediaDevices.getUserMedia({ video: true })
.then(stream=> video.srcObject = stream)
# Base length subtraction has to subtract file extension then re-add after
Dir | Rename-Item -NewName {$_.name.substring(3,$_.BaseName.length-4) + '.png'}
@LiamHz
LiamHz / karabiner.json
Created July 16, 2019 04:28
Map caps lock to l_control when used as modifier and esc when alone
{
"profiles": [
{
"name": "Default profile",
"selected": true,
"complex_modifications": {
"rules": [
{
"description": "A Modern Space Cadet (Steve Losh)",
"manipulators": [
@LiamHz
LiamHz / backup_ppm.cpp
Created February 2, 2020 08:08
Store the intermediate of a ppm file
// Store a backup ppm after rendering every 100 rows
if (j % 100 == 0) {
ofs.close();
temp_filename = "./out_" + std::to_string(ny-j) + ".ppm";
std::ifstream src("out.ppm", std::ios::binary);
std::ofstream dst(temp_filename, std::ios::binary);
dst << src.rdbuf();
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.liamhinzman.arbtt</string>
<key>Program</key>
<string>/Users/liamhinzman/screenshot.sh</string>
<key>RunAtLoad</key>
<true/>
@LiamHz
LiamHz / camera_marking_menu.py
Last active January 26, 2025 16:15
Creates a marking menu for switching between cameras (Maya script)
'''
Creates a marking menu for switching between cameras
Marking menu opens on Shift+MMB
Lists all cameras in a group named "Cameras"
Menu items will look through the selected camera
Menu item labels are created dynamically to match the order and names of your cameras
Marking menu code based on this blog post: http://bindpose.com/custom-marking-menu-maya-python/
'''
import maya.cmds as mc
@LiamHz
LiamHz / ubercam.py
Last active October 28, 2024 23:55
Create an ubercam for the camera sequencer, delete the previous one if it exists, set its display options, move it into the cameras group, bake camera keys, and handle "EnableSteppedPreview"
import maya.cmds as cmds
camera_name = 'ubercam'
cameras_group = 'Cameras'
overscan_value = 1.2
gate_color = (0.0, 0.0, 0.0)
gate_opacity = 1.0
if cmds.objExists(camera_name):