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
'''Visualization of the filters of VGG16, via gradient ascent in input space. | |
This script can run on CPU in a few minutes. | |
Results example: http://i.imgur.com/4nj4KjN.jpg | |
''' | |
from __future__ import print_function | |
import numpy as np | |
import time | |
from keras.preprocessing.image import save_img | |
from keras.applications import vgg16 |
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
# coding: utf-8 | |
__author__ = 'rishab-sharma' | |
import os | |
os.environ["CUDA_VISIBLE_DEVICES"] = "0" | |
import keras | |
from keras.preprocessing import image | |
from keras.models import Model | |
from keras.layers import Dense, GlobalAveragePooling2D , Dropout |
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
export IMAGE_FAMILY="pytorch-latest-gpu" | |
export ZONE="us-west1-b" | |
export INSTANCE_NAME="human-seg" | |
export INSTANCE_TYPE="n1-standard-8" | |
gcloud compute instances create $INSTANCE_NAME \ | |
--zone=$ZONE \ | |
--image-family=$IMAGE_FAMILY \ | |
--machine-type=$INSTANCE_TYPE \ | |
--image-project=deeplearning-platform-release \ | |
--maintenance-policy=TERMINATE \ |
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 cv2 | |
import numpy as np | |
from glob import glob | |
import requests | |
import os | |
def get_video(video_url): | |
r = requests.get(video_url, stream = True) | |
with open('./vid.mp4', 'wb') as f: | |
for chunk in r.iter_content(chunk_size = 1024*1024): |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torchvision | |
from functools import partial | |
class DilatedResnet18MaxPool(nn.Module): | |
def __init__(self, fc_dim=64, conv_size=3): | |
super(DilatedResnet18MaxPool, self).__init__() |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
# Code from Hang Zhao (@hangzhaomit) | |
class Unet(nn.Module): | |
def __init__(self, fc_dim=64, num_downs=5, ngf=64, use_dropout=False): | |
super(Unet, self).__init__() | |
# construct unet structure |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
# Code from Hang Zhao (@hangzhaomit) | |
class InnerProd(nn.Module): | |
def __init__(self, fc_dim): | |
super(InnerProd, self).__init__() | |
self.scale = nn.Parameter(torch.ones(fc_dim)) | |
self.bias = nn.Parameter(torch.zeros(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
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt |