Skip to content

Instantly share code, notes, and snippets.

View priya-dwivedi's full-sized avatar

Priyanka Dwivedi priya-dwivedi

  • Deep Learning Consultant
  • Toronto, Canada
View GitHub Profile
@priya-dwivedi
priya-dwivedi / kg_all_candidates.py
Created May 28, 2020 14:58
Knowldge Graph for all the candidates
edge_dict = {}
edge_dict[names[0]] = languages1
edge_dict[names[1]] = languages2
edge_dict[names[2]] = languages2
G=nx.from_dict_of_lists(edge_dict,create_using=nx.MultiDiGraph())
plt.figure(figsize=(12,12))
pos = nx.circular_layout(G)
@priya-dwivedi
priya-dwivedi / kg_matthew.py
Created May 28, 2020 14:51
Knowledge Graph for a single candidate
import networkx as nx
edge_dict = {}
edge_dict['Mathew'] = languages_mathew
# create a directed-graph from a dataframe
G=nx.from_dict_of_lists(edge_dict,create_using=nx.MultiDiGraph())
plt.figure(figsize=(12,12))
pos = nx.spring_layout(G)
nx.draw(G, with_labels=True, node_color='skyblue', edge_cmap=plt.cm.Blues, pos = pos, node_size = 4500)
plt.show()
@priya-dwivedi
priya-dwivedi / extract_programming_languages.py
Created May 28, 2020 14:41
Extract Programming Languages from a resume
import docx2txt
def extract_programming_languages(file_name):
# read in word file
result = docx2txt.process(file_name)
programming_languages_pattern = re.search(r'Programming Languages:[A-Za-z,\s0-9]*\.',result)
print(programming_languages_pattern)
programming_languages_line = programming_languages_pattern.group(0)
languages = re.sub("Programming Languages: ","", programming_languages_line)
@priya-dwivedi
priya-dwivedi / social_distancing.py
Created May 6, 2020 11:10
modeling social distance
def model_distancing(df, proximity):
print("Simulation Started")
time1 = time.time()
max_frame = df['frame_num'].max()
for frame_num in range(3, max_frame):
pairs_done = []
if frame_num % 50 == 0:
print("Completed: ", frame_num)
## Look at all tracks in this frame
def distance_boxes (boxA, boxB):
import math
center_boxA = [(boxA[0] + boxA[2])/ 2.0, (boxA[1] + boxA[3])/2.0]
center_boxB = [(boxB[0] + boxB[2])/ 2.0, (boxB[1] + boxB[3])/2.0]
pixel_distance = math.sqrt( ((center_boxA[0]-center_boxB[0])**2)+((center_boxA[1]-center_boxB[1])**2) )
return pixel_distance
class CustomDataset(utils.Dataset):
def load_custom(self, dataset_dir, subset):
"""Load a subset of the Balloon dataset.
dataset_dir: Root directory of the dataset.
subset: Subset to load: train or val
"""
# Add classes. We have only one class to add.
self.add_class("damage", 1, "damage")