Skip to content

Instantly share code, notes, and snippets.

View nrupatunga's full-sized avatar

Nrupatunga nrupatunga

View GitHub Profile
# Required packages: torch
# Desired packages: numpy, matplotlib
# Add missing imports:
def main():
training_images = {x for x in range(1, 100001)}
priority_images = {x * 100 for x in range(1, 11)}
# Task:
# 1. Dataloader needs to return a batch of size 10. Each element is a unique element from `training_images`.
# 2. Elements from `priority_images` must be present in EVERY batch with the ratio 1:1, meaning that batch will have
@nrupatunga
nrupatunga / README.md
Created December 3, 2021 06:47
[JointVAE][Digits]: Ambiguous Data generation using latent dimensions and testing Different Models.

This is the video demonstration

export CONTAINER_URI="gcr.io/deeplearning-platform-release/experimental.theia.1-7"
export INSTANCE_NAME=...
export PROJECT_NAME=...
export IMAGE_PROJECT="deeplearning-platform-release"
export IMAGE_FAMILY="theia-container-experimental"
export MACHINE_TYPE=... #"n1-standard-4"
export ZONE=... #"us-central1-a"
gcloud compute instances create "${INSTANCE_NAME}" \
--project="${PROJECT_NAME}" \
--zone="${ZONE}" \
export CONTAINER_URI="gcr.io/deeplearning-platform-release/experimental.theia.1-7"
export INSTANCE_NAME=...
export PROJECT_NAME=...
export IMAGE_PROJECT="deeplearning-platform-release"
export IMAGE_FAMILY="theia-container-experimental"
export MACHINE_TYPE=... #"n1-standard-4"
export ZONE=.... #"us-central1-a"
gcloud notebooks instances create "${INSTANCE_NAME}" \
--project="${PROJECT_NAME}" \
--location="${ZONE}" \
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms
from torchvision.datasets import MNIST
from torch.utils.data import random_split, DataLoader
import pytorch_lightning as pl
class LitModel(pl.LightningModule):
def __init__(self, channels, width, height, num_classes, hidden_size=64, learning_rate=2e-4):
super().__init__()
@nrupatunga
nrupatunga / elastic_transform.py
Created May 18, 2020 17:01 — forked from fmder/elastic_transform.py
Elastic transformation of an image in Python
import numpy
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@nrupatunga
nrupatunga / slack_notifier.py
Created December 6, 2019 08:21 — forked from abhishekkrthakur/slack_notifier.py
Slack notification from python
import os
import requests
import json
SLACK_WEBHOOK= os.environ.get("SLACK_WEBHOOK")
def send_message(messages, channel="abhishek", username="beast"):
"""
:param messages: list of texts
import requests
from lxml import html
# conferences = ["CVPR2013","ICCV2013","CVPR2014","CVPR2015"]
# conferences = ["CVPR2017","ICCV2017","CVPR2016","ICCV2016"]
conferences = ["CVPR2018"]
for conf in conferences:
# Get the HTML text and find the classes of type 'ptitle'
response = requests.get("http://openaccess.thecvf.com/" + conf + ".py")
@nrupatunga
nrupatunga / data_loader.py
Created January 11, 2018 10:39 — forked from kevinzakka/data_loader.py
Train, Validation and Test Split for torchvision Datasets
# This is an example for the CIFAR-10 dataset.
# There's a function for creating a train and validation iterator.
# There's also a function for creating a test iterator.
# Inspired by https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4
from utils import plot_images
def get_train_valid_loader(data_dir,
batch_size,
augment,