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
from azureml.core.webservice import AciWebservice, Webservice | |
from azureml.core.model import Model | |
aspect_lex = Model(ws, 'aspect_lex') | |
opinion_lex = Model(ws, 'opinion_lex') | |
service = Model.deploy(workspace=ws, | |
name='absa-srvc', | |
models=[aspect_lex, opinion_lex], | |
inference_config=inference_config, |
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
from azureml.core.model import InferenceConfig | |
inference_config = InferenceConfig(environment=deploy_env, | |
entry_script="score.py") |
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
from azureml.core import Environment | |
deploy_env = Environment.from_conda_specification('absa_env', "myenv.yml") | |
deploy_env.environment_variables={'NLP_ARCHITECT_BE': 'CPU'} |
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
from azureml.core.conda_dependencies import CondaDependencies | |
pip = ["azureml-defaults", "azureml-monitoring", "git+https://github.com/NervanaSystems/nlp-architect.git@absa"] | |
myenv = CondaDependencies.create(pip_packages=pip) | |
with open("myenv.yml","w") as f: | |
f.write(myenv.serialize_to_string()) |
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
from azureml.core.webservice import AciWebservice | |
aciconfig = AciWebservice.deploy_configuration(cpu_cores=1, | |
memory_gb=1, | |
tags={"data": "text", "method" : "NLP Architcet ABSA"}, | |
description='Predict ABSA with NLP Architect') | |
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
from azureml.core.compute import ComputeTarget, AmlCompute | |
from azureml.core.compute_target import ComputeTargetException | |
cluster_name = "cluster" | |
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D3_V2', # VM Size N series have GPU | |
vm_priority='lowpriority', # Cheap Computer | |
min_nodes=0, # Auto Scale Min Limit | |
max_nodes=5) #Auto Scale Max Limit | |
cluster = ComputeTarget.create(ws, cluster_name, compute_config) | |
cluster.wait_for_completion(show_output=True) |
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
from azureml.train.estimator import Estimator | |
script_params = { | |
'--data_folder': ds, | |
} | |
nlp_est = Estimator(source_directory='.', | |
script_params=script_params, | |
compute_target=cluster, | |
entry_script='train.py', |
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
########### Python Form Recognizer Train ############# | |
from requests import post as http_post | |
# Endpoint URL | |
base_url = r"<Endpoint>" + "/formrecognizer/v1.0-preview/custom" | |
source = r"<SAS URL>" | |
headers = { | |
# Request headers | |
'Content-Type': 'application/json', | |
'Ocp-Apim-Subscription-Key': '<Subscription Key>', |
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 | |
# If you are using a Jupyter notebook, uncomment the following line. | |
#%matplotlib inline | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Rectangle | |
from PIL import Image | |
from io import BytesIO | |
# Replace <Subscription Key> with your valid subscription key. | |
subscription_key = "" |
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
//http://www.easyrgb.com/en/math.php | |
function tfRGB2LAB(rgb) { | |
let a_con = tf.pow(rgb.add(0.055).div(1.055), 2.4); | |
let b_con = rgb.div(12.92); | |
let rgb_2 = tf.where(rgb.greater(0.04045), a_con, b_con); | |
const [r, g, b] = rgb_2.split(3, 2); | |
let x = r |