Skip to content

Instantly share code, notes, and snippets.

View preddy5's full-sized avatar

Pradyumna Reddy Chinthala preddy5

View GitHub Profile
import json
import PIL
from PIL import Image
from DC.compositing import composite, seed, composite_l2, composite_layers, composite_layers_A
from DC.loss import loss_fn, loss_fn_l2
from DC.sampling import sampling_layer
import torch
def create_img(xy, elements, background, element_id, thetas, width=256, height=256, scale=1.0, gen_img=None, color=None, background_img=None):
scale= int(scale)
canvas_size = [width*scale, height*scale]
xy = xy*scale
for i in range(len(elements)):
w_e = elements[i].size[0]
h_e = elements[i].size[1]
elements[i] = elements[i].resize((w_e*scale, h_e*scale), resample=PIL.Image.BICUBIC)
namespace_map = {0:'A', 1:'B', 2:'C', 3:'D', 4:'E', 5:'F', 6:'G', 7:'H'}
alpha_mask = 0
import xml.etree.ElementTree as etree
from xml.dom import minidom
def prettify(elem):
"""Return a pretty-printed XML string for the Element.
"""
rough_string = etree.tostring(elem, 'utf-8')
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
import numpy as np
import matplotlib.pyplot as plt
def hard_composite(A, B):
alpha_A = A[:, :, 3:4]
alpha_B = B[:, :, 3:4]
# A over B
final_composite = A * alpha_A + B * alpha_B * (1 - alpha_A)
layer {
name: "data"
type: "Data"
top: "data"
input_param {
shape: { dim: 1 dim: 3 dim: 384 dim: 384 }
}
}
layer {
name: "conv1_1"
name: "VGG_text_longer_conv_300x300_deploy"
input: "data"
input_shape {
dim: 1
dim: 3
dim: 700
dim: 700
}
layer {
name: "conv1_1"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<polymer-element name="my-element">
<template>
<style>
:host {
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 20em;
@preddy5
preddy5 / gist:5746728
Created June 10, 2013 05:28
find postion of a html element using javascript
function getOffset( el ) {
var _x = 0;
var _y = 0;
while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
_x += el.offsetLeft - el.scrollLeft;
_y += el.offsetTop - el.scrollTop;
el = el.offsetParent;
}
return { top: _y, left: _x };
}