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
# Test Movie methods | |
query = "The Karate Kid" | |
moviesDB = imdb.IMDb() | |
movies = moviesDB.search_movie(find_imdb(query)) | |
id = movies[0].getID() | |
score = rotten_tomatoes_score(find_imdb(query)) | |
movie = moviesDB.get_movie(id) | |
title = movie['title'] | |
year = movie['year'] | |
rating = movie['rating'] |
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 sports | |
# Sports function | |
def scores(query): | |
try: | |
result = [] | |
all_matches = sports.all_matches() | |
keys = list(all_matches.keys()) | |
for j in range(len(keys)): | |
temp = all_matches[keys[j]] | |
matches = [] |
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 smtplib | |
def send_mail(subject, body, reciever): | |
server = smtplib.SMTP('smtp.gmail.com', 587) | |
server.ehlo() | |
server.starttls() | |
server.ehlo() | |
server.login(config.email, config.password) | |
msg = f"Subject: {subject}\n\n{body}" | |
server.sendmail(config.email, reciever, msg) | |
server.quit() |
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
if __name__ == "__main__": | |
greet() | |
city, country, latitude, longitude = get_location() | |
while True: | |
query = listen().lower() | |
if 'stock' in query: | |
pass | |
elif 'weather' in query or 'temperature' in query: | |
pass | |
elif 'movie' in query or 'documentary' in query: |
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 Libraries | |
import os | |
import cv2 | |
import glob | |
import pandas as pd | |
import xml.etree.ElementTree as ET | |
import numpy as np | |
import tensorflow as tf | |
from object_detection.utils import config_util | |
from object_detection.protos import pipeline_pb2 |
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
# Setup Paths | |
WORKSPACE_PATH = 'Tensorflow/workspace' | |
SCRIPTS_PATH = 'Tensorflow/scripts' | |
APIMODEL_PATH = 'Tensorflow/tensorflow-models/models' | |
ANNOTATION_PATH = WORKSPACE_PATH+'/annotations' | |
IMAGE_PATH = WORKSPACE_PATH+'/images' | |
MODEL_PATH = WORKSPACE_PATH+'/models' | |
PRETRAINED_MODEL_PATH = WORKSPACE_PATH+'/pre-trained-models' | |
CONFIG_PATH = MODEL_PATH+'/my_ssd_mobnet/pipeline.config' | |
CHECKPOINT_PATH = MODEL_PATH+'/my_ssd_mobnet/' |
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
# Label Map | |
def construct_label_map(): | |
labels = [{'name': 'Mask', 'id': 1}, {'name': 'NoMask', 'id': 2}] | |
with open(ANNOTATION_PATH + '\label_map.pbtxt', 'w') as f: | |
for label in labels: | |
f.write('item { \n') | |
f.write('\tname:\'{}\'\n'.format(label['name'])) | |
f.write('\tid:{}\n'.format(label['id'])) | |
f.write('}\n') |
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
# XML TO CSV | |
def xml_to_csv(path): | |
xml_list = [] | |
for xml_file in glob.glob(path + '/*.xml'): | |
tree = ET.parse(xml_file) | |
root = tree.getroot() | |
for member in root.findall('object'): | |
value = (root.find('filename').text+".jpg", | |
int(root.find('size')[0].text), | |
int(root.find('size')[1].text), |
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
# Configuration | |
def config(): | |
CONFIG_PATH = MODEL_PATH+'/'+CUSTOM_MODEL_NAME+'/pipeline.config' | |
config = config_util.get_configs_from_pipeline_file(CONFIG_PATH) | |
pipeline_config = pipeline_pb2.TrainEvalPipelineConfig() | |
with tf.io.gfile.GFile(CONFIG_PATH, "r") as f: | |
proto_str = f.read() | |
text_format.Merge(proto_str, pipeline_config) | |
# Modify pipeline | |
pipeline_config.model.ssd.num_classes = 2 |
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
# Load Model from checkpoints | |
def load_model(): | |
configs = config_util.get_configs_from_pipeline_file(CONFIG_PATH) | |
detection_model = model_builder.build( | |
model_config=configs['model'], is_training=False) | |
ckpt = tf.compat.v2.train.Checkpoint(model=detection_model) | |
ckpt.restore(os.path.join(CHECKPOINT_PATH, 'ckpt-9')).expect_partial() | |
return detection_model |