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
### 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 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
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 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
!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
document.getElementsByTagName("video")[0].playbackRate = 9001 |
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
from IPython.core.magic import register_cell_magic | |
from IPython.display import HTML, display | |
def set_background(color): | |
script = ( | |
"var cell = this.closest('.jp-CodeCell');" | |
"var editor = cell.querySelector('.jp-Editor');" | |
"editor.style.background='{}';" | |
"this.parentNode.removeChild(this)" | |
).format(color) |
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 torch, math | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class RetinaNet(nn.Module): | |
num_anchors = 9 | |
def __init__(self, num_classes): | |
super(RetinaNet, self).__init__() | |
self.fpn = FPN50() | |
self.num_classes = num_classes |
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
jt -t grade3 -fs 95 -tfs 11 -nfs 115 -cellw 95% -T | |
jt -t onedork -fs 95 -tfs 11 -nfs 115 -cellw 88% -T -N |