ICNR is an initialization method for sub-pixel convolution.
Papar
Github or Gist
| from PyQt5 import QtCore, QtGui, QtWidgets | |
| if __name__ == "__main__": | |
| import sys | |
| app = QtWidgets.QApplication(sys.argv) | |
| app.setStyle('Fusion') | |
| palette = QtGui.QPalette() | |
| palette.setColor(QtGui.QPalette.Window, QtGui.QColor(53,53,53)) | |
| palette.setColor(QtGui.QPalette.WindowText, QtCore.Qt.white) | |
| palette.setColor(QtGui.QPalette.Base, QtGui.QColor(15,15,15)) |
| from __future__ import print_function, absolute_import | |
| __all__ = ['accuracy'] | |
| def accuracy(output, target, topk=(1,)): | |
| """Computes the precision@k for the specified values of k""" | |
| maxk = max(topk) | |
| batch_size = target.size(0) | |
| _, pred = output.topk(maxk, 1, True, True) |
| import torch | |
| from torchvision import datasets | |
| class ImageFolderWithPaths(datasets.ImageFolder): | |
| """Custom dataset that includes image file paths. Extends | |
| torchvision.datasets.ImageFolder | |
| """ | |
| # override the __getitem__ method. this is the method that dataloader calls | |
| def __getitem__(self, index): |
| #!/usr/bin/python3 | |
| # -*- coding: utf-8 -*- | |
| from PyQt5.QtCore import Qt | |
| from PyQt5.QtGui import QImage, QPixmap, QPalette, QPainter | |
| from PyQt5.QtPrintSupport import QPrintDialog, QPrinter | |
| from PyQt5.QtWidgets import QLabel, QSizePolicy, QScrollArea, QMessageBox, QMainWindow, QMenu, QAction, \ | |
| qApp, QFileDialog |
| import onnx | |
| import torch | |
| from caffe2.python.onnx import backend | |
| from torch import nn | |
| from torch.autograd import Variable | |
| from torch.nn import PixelShuffle | |
| class MyPixelShuffle(nn.Module): | |
| """ | |
| Alternative version of pixel shuffle that was copied from the C++ version |
| # Lint as: python2, python3 | |
| # Copyright 2018 The TensorFlow Authors. All Rights Reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
ICNR is an initialization method for sub-pixel convolution.
Papar
Github or Gist
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from argparse import ArgumentParser | |
| import torch | |
| import torch.distributed as dist | |
| from torch.nn.parallel import DistributedDataParallel as DDP | |
| from torch.utils.data import DataLoader, Dataset | |
| from torch.utils.data.distributed import DistributedSampler | |
| from transformers import BertForMaskedLM |