Skip to content

Instantly share code, notes, and snippets.

@giannis-papaioannou
giannis-papaioannou / main.py
Created November 2, 2013 17:06
PyQt5 Dark Fusion Theme based on the cpp qt5 theme found here https://gist.github.com/Skyrpex/5547015
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))
@weiaicunzai
weiaicunzai / accuracy.py
Created June 22, 2018 13:20
compute top1, top5 error using pytorch
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)
@andrewjong
andrewjong / pytorch_image_folder_with_file_paths.py
Last active October 31, 2024 11:13
PyTorch Image File Paths With Dataset Dataloader
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):
@acbetter
acbetter / QImageViewer.py
Last active August 31, 2025 08:05
Image Viewer Example by PyQt5 and Python 3
#!/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
@geoffsmith
geoffsmith / test_pixelshuffle.py
Created June 12, 2019 12:41
Example showing PixelShuffle ONNX export doesn't use same ordering as PyTorch
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
@amaotone
amaotone / icnr_example.ipynb
Created July 29, 2019 04:30
Sub-Pixel Conv with ICNR
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bikcrum
bikcrum / tf_upgrade_v2.py
Last active October 20, 2021 07:30
Tensorflow migration script tf_upgrade_v2.py
# 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
@A03ki
A03ki / ICNR.md
Last active March 25, 2024 05:03
Implementation of ICNR with PyTorch
@sgraaf
sgraaf / ddp_example.py
Last active November 7, 2024 05:39
PyTorch Distributed Data Parallel (DDP) example
#!/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
@HanClinto
HanClinto / highresslowmo.ipynb
Created August 6, 2020 18:49
HighResSlowMo.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.