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 | |
from lxml import html | |
import pandas as pd | |
def scrape_table_with_links(url): | |
""" | |
Scrapes a table from a webpage, extracting both text and URLs from cells. | |
Specifically targets //form/table/tbody/tr[td] and extracts URLs from column 3. | |
Args: |
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 add_zoom_crop(img, crop_xs, crop_ys, r, inset_coord): | |
x1,x2 = crop_xs | |
y1,y2 = crop_ys | |
img = (img*255).astype(np.uint8) | |
inset_coord_end = ( int(inset_coord[0]+(x2-x1)*r), int(inset_coord[1] +(y2-y1)*r)) | |
patch = img[y1:y2,x1:x2] | |
patch_bigger = cv2.resize(patch, ( int(patch.shape[1]*r), int(patch.shape[0]*r))) | |
img[inset_coord[1]:inset_coord[1]+patch_bigger.shape[0], inset_coord[0]:inset_coord[0]+patch_bigger.shape[1]] = np.atleast_3d(patch_bigger) | |
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
######################## | |
# https://gist.github.com/alper111/b9c6d80e2dba1ee0bfac15eb7dad09c8 | |
def gauss_kernel(size=5, device=torch.device('cpu'), channels=3): | |
kernel = torch.tensor([[1., 4., 6., 4., 1], | |
[4., 16., 24., 16., 4.], | |
[6., 24., 36., 24., 6.], | |
[4., 16., 24., 16., 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
def group_weight(module, lr_encoder, lr_decoder, WD): | |
group_decay = { 'encoder': [], 'decoder':[]} | |
group_bias = { 'encoder': [], 'decoder':[]} | |
group_GN = { 'encoder': [], 'decoder':[]} | |
for name, m in module.named_modules(): | |
# if hasattr(m, 'requires_grad'): | |
# if m.requires_grad: | |
# continue |
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
name: "color" | |
input: "data" | |
input_dim: 1 | |
input_dim: 4 | |
input_dim: 256 | |
input_dim: 256 | |
layer { | |
name: "data_l_ab_mask" | |
type: "Input" | |
top: "data_l_ab_mask" |
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
name: "RED-Net" | |
input: "data" | |
input_dim: 1 | |
input_dim: 3 | |
input_dim: 256 | |
input_dim: 256 | |
# conv1 | |
layer { | |
name: "conv1" |
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Primarily about computing factorials" | |
] | |
}, | |
{ |
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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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
""" This module shows how to retrieve the duration of an audio or video file on Windows by getting the file details | |
with Powershell, tested on Powershell 4. """ | |
import subprocess | |
myFileLocation = r"'C:\Users\Marco\Untitled.wma'" # or myFileLocation = 'C:\\Users\\yourname\\test.mp4' | |
def getFileDuration(fileLocation): | |
# Calls the Powershell script that gets the file duration | |
return subprocess.check_output([r'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe', | |
'(((New-Object -COMObject Shell.Application).Namespace((Split-Path {0})))).GetDetailsOf((((New-Object -COMObject Shell.Application).Namespace((Split-Path {0}))).ParseName((Split-Path {0} -Leaf))), 183);'.format(myFileLocation)]).decode("utf-8").splitlines()[0] |