This file contains hidden or 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 main(): | |
| target = torch.randint(-20, 20, (8, 3, 4, 4)).float() | |
| source = torch.randint(-20, 20, (8, 3, 4, 4)).float() | |
| stylized_source = adain(source, target) | |
| target = target.view(8, 3, -1) | |
| stylized_source = stylized_source.view(8, 3, -1) | |
| # check variances the same |
This file contains hidden or 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
| features_list = [] | |
| for layer in features: | |
| features_list.append(layer) | |
| if isinstance(layer, nn.Conv2d): | |
| features_list.append(nn.BatchNorm2d(layer.out_channels)) | |
| del features_list[-1] | |
| self.features = nn.Sequential(*features_list) |
This file contains hidden or 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 __next__(self): | |
| if self.ilength <= 0: | |
| raise StopIteration | |
| self.ilength -= 1 | |
| coco_idx, wiki_idx = self.random_pair_of_indices() | |
| content_image = self.coco[coco_idx][0] | |
| if not self.exclude_style: |
This file contains hidden or 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 train_epoch_style_loss(args, encoder, decoder, dataloader, val_dataloader, | |
| optimizer, epoch_num, writer, run, device): | |
| encoder.eval() | |
| decoder.train() | |
| total_loss = 0 | |
| num_batches = calc_num_batches(dataloader, args) | |
| progress_bar = tqdm.tqdm(enumerate(dataloader), total = num_batches, dynamic_ncols = True) | |
| for i, (content_image, style_image) in progress_bar: | |
| # mvoe to gpu |
This file contains hidden or 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 get_style_transfer_loss(encoder, decoder, content_image, style_image, lambda_content, lambda_style): | |
| assert_shape(content_image, (g_batch_size, 3, 256, 256)) | |
| style_features = encoder(style_image) | |
| content_features = encoder(content_image) | |
| stylized_images, stylized_features = create_stylized_images(decoder, content_features, style_features) | |
| features_of_stylized = encoder(stylized_images) |
This file contains hidden or 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": "Detexify", | |
| "description": "Symbol Recognition for Overleaf", | |
| "version": "1.0", | |
| "manifest_version": 2, | |
| "content_scripts": [{ | |
| "js": ["content.js"], | |
| "css": ["style.css"], | |
| "matches": ["https://www.overleaf.com/project/*"] |
This file contains hidden or 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
| addExtexifyButton() | |
| addExtexifyPane() | |
| addToggleExtexifyCallbacks() | |
| hideExtexify() | |
| clearCanvas() | |
| addDrawingCallbacks() |
This file contains hidden or 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 addExtexifyPane() { | |
| const editor = document.getElementById("editor") | |
| const extexifyPane = document.createElement("div"); | |
| extexifyPane.classList.add("extexify-pane") | |
| editor.appendChild(extexifyPane) | |
| const backdrop = document.createElement("div"); | |
| backdrop.classList.add("extexify-backdrop") | |
| editor.appendChild(backdrop) |
This file contains hidden or 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 toggleExtexify() { | |
| document.getElementsByClassName("extexify-pane")[0].classList.toggle("fade-out") | |
| document.getElementsByClassName("extexify-backdrop")[0].classList.toggle("fade-out") | |
| var canvas = document.getElementById("extexify-canvas"); | |
| canvas.width = canvas.clientWidth; | |
| canvas.height = canvas.clientHeight; | |
| points = [[]]; | |
| } |