Skip to content

Instantly share code, notes, and snippets.

@ylashin
ylashin / download-sequential.ps1
Last active December 26, 2016 12:09
Downloads files/images from a SharePoint online lilbrary in sequence using Office Dev Pnp Powershell commands
Connect-PnPOnline –Url "YOUR-SITE_URL" –Credentials (Get-Credential)
$web = Get-PnPWeb
$files = Get-PnPListItem -List "YOUR-LIST-NAME"
for($i=0; $i -lt $files.Count; $i++)
{
$web.Context.Load($files[$i].File)
}
@ylashin
ylashin / download-parallel.ps1
Last active December 26, 2016 01:37
Download images/files in a SharePoint online library using Office Dev PnP Powershell commands. The download done in parallel using Powershell background jobs. There is some code duplication due to the way background jobs running in their own context (and also my limited PS skills :) ). Also the script does not handle files with same names in dif…
function Split-array
{
param($inArray,[int]$parts,[int]$size)
if ($parts) {
$PartSize = [Math]::Ceiling($inArray.count / $parts)
}
if ($size) {
$PartSize = $size
@ylashin
ylashin / azure-ml-service.md
Last active October 2, 2018 04:50
DDD Brisbane 2018

Azure Machine Learning done right!

Disclaimer: this isn't about the old classic drag and drop ML studio!

Developing machine learning models or data science applications on Microsoft stack is not a very nice experience. The main tool is Azure Machine Learning Studio and it doesn't provide a good story for DevOps, Source Control or using open source ML tools/IDEs heavily used by data scientists.

A new cloud service has been recently added to Azure to solve those problems and make ML and app development go hand in hand and in harmony.

Meet Azure Machine Learning Service! It's a one-stop shop that you can use to develop, deploy and manage machine learning models.

@ylashin
ylashin / consume-yolo.cs
Last active October 20, 2018 12:59
Consume YOLO
var webServiceUrl = ConfigurationManager.AppSettings["WebServiceUrl"];
var client = new RestClient(webServiceUrl);
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
var payload = PrepareWebRequest(imageFilePath);
request.AddJsonBody(payload);
var response = client.Execute(request);
var content = response.Content;
! az login
! az account list -o table
! az account set --subscription 'YOUR SUBSCRIPTION NAME'
! pip install matplotlib onnx
! wget https://www.cntk.ai/OnnxModels/tiny_yolov2/opset_7/tiny_yolov2.tar.gz
! tar xvzf tiny_yolov2.tar.gz
# Check core SDK version number
import azureml.core
print("SDK version:", azureml.core.VERSION)
from azureml.core import Workspace
ws = Workspace(subscription_id="YOUR SUBSCRIPTION ID", resource_group="YOLO", workspace_name="YOLO")
print(ws.name, ws.resource_group, ws.location, sep = '\n')
model_dir = "tiny_yolov2"
from azureml.core.model import Model
model = Model.register(model_path = model_dir + "//model.onnx",
model_name = "tiny_yolov2",
tags = {"onnx": "demo"},
description = "Tiny YOLO model",
workspace = ws)