Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Non-Traditional Usage of Microsoft Azure Cloud for Science Art

Non-Traditional Usage of Microsoft Azure Cloud for Science Art

D8730970396729af16546cc69ce63b44?s=128

Dmitri Soshnikov

September 02, 2021
Tweet

Transcript

  1. Non-Traditional Usage of Microsoft Azure Cloud for Science Art

  2. # whoami Cloud Developer Advocate - Talks, Blogs, etc. -

    Product Feedback Associate Professor - Artificial Intelligence - Functional and Logic Programming Software Developer/ Data Scientist - Pilot projects with large companies in Europe
  3. None
  4. Datacenter Hardware Compute Storage Virtual Machine Azure Batch AKS (Cluster)

    CosmosDB Azure SQL Data Lake Table Queue Blob File Share Azure ML Bot Framework Azure Web App Azure Function Azure IoT Databricks Vision Face Custom Vision LUIS + Text QnA Maker Power BI Power Apps IaaS PaaS PaaS+
  5. http://github.com/CloudAdvocaty/CognitivePortrait

  6. def affine_transform(img,attrs): mc_x = (attrs['mouth_left']['x’]+ attrs['mouth_right']['x'])/2.0 mc_y = (attrs['mouth_left']['y’]+ attrs['mouth_right']['y'])/2.0

    tr = cv2.getAffineTransform(np.float32([( attrs['pupil_left']['x’], attrs['pupil_left'][‘y’], (attrs['pupil_right']['x’], attrs['pupil_right']['y']), (mc_x,mc_y)]), target_triangle) return cv2.warpAffine(img,tr,(size,size))
  7. Dmitry Soshnikov, «Growing Up» 2020, cognitive portrait

  8. None
  9. None
  10. None
  11. None
  12. UWP App Exhibition 2 (ANYWHERE) Exhibition 1 (Moscow) CLIENT (AT

    MUSEUM) CLOUD UWP App
  13. None
  14. None
  15. $ func init coportrait –python $ cd coportrait $ func

    new --name pdraw --template "HTTP trigger“ $ func start
  16. def

  17. def main(req:func.HttpRequest) -> func.HttpResponse: logging.info('Execution begins…') name = req.params.get('name') if

    name: return func.HttpResponse(f"Hello {name}!") else: return func.HttpResponse( “Need name query parameter", status_code=400) { "scriptFile": "__init__.py", "bindings": [ { "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "req", "methods": [ "get", "post" ]}, { "type": "http", "direction": "out", "name": "$return" }]}
  18. blob = BlockBlobService(account_name=acct_name, account_key=acct_key) body = req.get_body() sec_p = int((end_date-datetime.datetime.now()).total_seconds())

    name = f"{sec_p:09d}-"+time.strftime('%Y%m%d-%H%M%S') blob.create_blob_from_bytes("cin",name,body) img = imdecode(body)
  19. cogface = cf.FaceClient(endpoint,CognitiveServicesCredentials(key)) res = cogface.face.detect_with_stream(io.BytesIO(body), return_face_landmarks=True) if res is

    not None and len(res)>0: tr = affine_transform(img,res[0].face_landmarks.as_dict()) _,body = cv2.imencode('.jpg',tr) blob.create_blob_from_bytes("cmapped",name,body.tobytes())
  20. imgs = [ imdecode(blob.get_blob_to_bytes("cmapped",x.name).content) for x in itertools.islice(blob.list_blobs("cmapped"),10) ] imgs

    = np.array(imgs).astype(np.float32)/255.0 res = (np.average(imgs,axis=0)*255.0).astype(np.uint8) b = cv2.imencode('.jpg',res)[1] r = blob.create_blob_from_bytes("out",f"{name}.jpg",b.tobytes()) return func.HttpResponse(f"https://{act}.blob.core.windows.net/out/{name}.jpg")
  21. $ func azure functionapp publish <name> az functionapp create --resource-group

    <group> --os-type Linux --consumption-plan-location westeurope --runtime python --runtime-version 3.7 --functions-version 2 --name <APP_NAME> --storage-account <STORAGE_NAME>
  22. None
  23. None
  24. None
  25. None
  26. UWP App Virtual Exhibit REAL Exhibit CLIENT (AT HOME) CLIENT

    (AT MUSEUM) CLOUD Web App
  27. Bot Logic (WebAPI in the cloud) https://docs.botframework.com/

  28. None
  29. None
  30. None
  31. None
  32. Azure Machine Learning Workspace Dataset Datastore Compute Compute Cluster Experiments

    Notebooks Model Deployment Designer AutoML
  33. How Generative Adversarial Networks Work Random Vector Generator (Neural Net)

    Discriminator (Neural Net) ✓ ✗
  34. More Details on the Project http://eazify.net/azml_gan http://github.com/CloudAdvocacy/AzureMLStarter

  35. None