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 cv2 | |
import os | |
dim1,dim2 = 28,28 | |
founders=['Jeff Bezos','Larry Page','Bill Gates'] | |
for founder in founders: | |
#prefix=r'.\data\google\{}'.format(founder) |
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 azure.cognitiveservices.search.imagesearch import ImageSearchAPI | |
from msrest.authentication import CognitiveServicesCredentials | |
from PIL import Image | |
import requests | |
from io import BytesIO | |
import os | |
# create an Azure account | |
# and get your API key from here: | |
# https://azure.microsoft.com/en-us/services/cognitive-services/bing-image-search-api/ |
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 google_images_download import google_images_download | |
downloader=google_images_download.googleimagesdownload() | |
## if we want to retrieve more than 100 images from google drive we need to download chromedriver | |
cd_path='C:\Program Files\chromedriver_win32\chromedriver.exe' | |
output_dir=r'./data/google/' | |
founders=['Jeff Bezos','Larry Page','Bill Gates'] |
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 cv2 | |
import json | |
import numpy as np | |
def from_image_to_json(image_directory): | |
image=cv2.imread(image_directory) | |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml") | |
faces = faceCascade.detectMultiScale( |
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 cv2 | |
import requests | |
key1, Key2 = service.get_keys() | |
def get_founder(image_directory): | |
image=cv2.imread(image_directory) | |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | |
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml") |
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
## deploy the model to the ACI (azure container instances) | |
from azureml.core.webservice import AciWebservice | |
from azureml.core.model import InferenceConfig | |
from azureml.core.webservice import Webservice | |
from azureml.core.model import Model | |
inference_config = InferenceConfig(runtime= "python", ## runtime for the image, either python or spark-py | |
entry_script="score.py", | |
conda_file="myenv.yml") ##dependencies |
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 | |
from tensorflow.contrib import predictor | |
from azureml.core.model import Model | |
import json | |
def init(): | |
global loaded_model | |
saved_model_location=Model.get_model_path('founder-classifier-test') |
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
## create the myenv.yml to install the necessary packages on the Docker image | |
from azureml.core.runconfig import CondaDependencies | |
cd = CondaDependencies.create() | |
cd.add_conda_package('tensorflow') | |
cd.save_to_file(base_directory='./', conda_file_path='myenv.yml') | |
print(cd.serialize_to_string()) |
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 azureml.core.model import Model | |
model_dir='./outputs/founder-classifier/outputs/model/1570442423' | |
# Tip: When model_path is set to a directory, you can use the child_paths parameter to include | |
# only some of the files from the directory | |
model = Model.register(model_path = model_dir, | |
model_name = "founder-classifier", | |
description = "classification of founders using CNN", | |
workspace = ws) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.