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 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 |
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
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 |
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 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=" ") | |
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 | |
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) |
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
layer { | |
name: "data" | |
type: "Data" | |
top: "data" | |
input_param { | |
shape: { dim: 1 dim: 3 dim: 384 dim: 384 } | |
} | |
} | |
layer { | |
name: "conv1_1" |
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
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.
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
<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 { |
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
<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; |
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
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 }; | |
} |
NewerOlder