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
!pip install PyDrive | |
from pydrive.auth import GoogleAuth | |
from pydrive.drive import GoogleDrive | |
from google.colab import auth | |
from oauth2client.client import GoogleCredentials | |
auth.authenticate_user() | |
gauth = GoogleAuth() | |
gauth.credentials = GoogleCredentials.get_application_default() | |
drive = GoogleDrive(gauth) |
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
import cv2, os | |
def stem(fpath): return '.'.join(fname(fpath).split('.')[:-1]) | |
def convert_mp4_to_frames(filename): | |
vidcap = cv2.VideoCapture(filename) | |
success,image = vidcap.read() | |
count = 0 | |
while success: | |
os.makedirs(stem(filename), exist_ok=True) | |
cv2.imwrite(f"{stem(filename)}/{count}.jpg", image) # save frame as JPEG file |
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 subplots(ims, nc=5, figsize=(5,5), **kwargs): | |
if len(ims) == 0: return | |
titles = kwargs.pop('titles',[None]*len(ims)) | |
nr = (len(ims)//nc) if len(ims)%nc==0 else (1+len(ims)//nc) | |
logger.info(f'plotting {len(ims)} images in a grid of {nr}x{nc} @ {figsize}') | |
fig, axes = plt.subplots(nr,nc,figsize=figsize) | |
axes = axes.flat | |
for ix,(im,ax) in enumerate(zip(ims,axes)): | |
show(im, ax=ax, title=titles[ix], **kwargs) | |
blank = (np.eye(100) + np.eye(100)[::-1]) |
This file has been truncated, but you can view the full file.
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
<!DOCTYPE html> | |
<html> | |
<head><meta charset="utf-8" /> | |
<title>Untitled1</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
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
### Download a file to Local System from Colab | |
from google.colab import files | |
with open('example.txt', 'w') as f: | |
f.write('some content') | |
files.download('example.txt') | |
#====================================================================================================== | |
#upload file to Colab from Local System | |
from google.colab import files | |
uploaded = files.upload() |
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
import numpy as np | |
import cv2 | |
random_transform_args = { | |
'rotation_range': 10, | |
'zoom_range': 0.05, | |
'shift_range': 0.05, | |
'random_flip': 0.4, | |
} |
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
import requests | |
import getpass | |
import sys | |
LOGIN_URL = "http://zeus.robots.ox.ac.uk/vgg_face2/login/" | |
FILE_URL = "http://zeus.robots.ox.ac.uk/vgg_face2/get_file?fname=vggface2_test.tar.gz" | |
print('Please enter your VGG Face 2 credentials:') | |
user_string = input(' User: ') | |
password_string = getpass.getpass(prompt=' Password: ') |
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
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/Untitled.ipynb (unless otherwise specified). | |
__all__ = ['iou', 'patch', 'multi_patch'] | |
# Cell | |
#export | |
from torch_snippets import * | |
def iou(A,B): | |
A = np.array(A) | |
B = np.array(B) |
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
CRICKET O | |
- O | |
LEICESTERSHIRE I-ORG | |
TAKE O | |
OVER O | |
AT O | |
TOP O | |
AFTER O | |
INNINGS O | |
VICTORY O |
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
import sys | |
import io | |
import os | |
from IPython.nbformat.current import read, write | |
def remove_outputs(nb): | |
"""remove the outputs from a notebook""" | |
for ws in nb.worksheets: | |
for cell in ws.cells: | |
if cell.cell_type == 'code': |