<jupyter_start><jupyter_text>Setting Up the Sample Specific EnvironmentIn this section, we will be creating environmental variables specific to this sample.  Get Global Variables<jupyter_code>import sys
sys.path.append('../../../common')
from env_variables import *<jupyter_output><empty_output><jupyter_text>Set Environmental Variables Specific to This SampleIn the following sections, we will be creating a VM to act as our IoT Edge device. The following cell will set the type of VM that will be created. Verify that the VM type is available in your region. You may view this page for a full list of [VMs by region](https://azure.microsoft.com/en-us/global-infrastructure/services/?regions=non-regional,us-east,us-east-2,us-central,us-north-central,us-south-central,us-west-central,us-west,us-west-2&products=virtual-machines).For this sample, we will be using a Standard_DS3_v2 (CPU tier) VM.<jupyter_code>vm_type = "Standard_DS3_v2" #CPU tier VM
tempVar = set_key(envPath, "VM_TYPE", vm_type)<jupyter_output><empty_output><jupyter_text>The following cell will set a sample folder path absolute to the root folder of the repository.<jupyter_code>lvaSamplePath = "utilities/video-analysis/notebooks/yolo/yolov4/yolov4-grpc-icpu-onnx"
tempVar = set_key(envPath, "LVA_SAMPLE_PATH", lvaSamplePath)<jupyter_output><empty_output><jupyter_text>In later sections, we will be creating a Docker container image for our inference solution. The following cell will set the name of the Docker image to be used later.<jupyter_code>containerImageName = "lvaextension:grpc.yolov4.v1"
tempVar = set_key(envPath, "CONTAINER_IMAGE_NAME", containerImageName)<jupyter_output><empty_output><jupyter_text>The following cell will set the folder to which debug files will be outputted in the IoT Edge device. The default location for debug files is `/tmp` folder in your IoT Edge device. If you want debug files to be sent elsewhere, you can change the value of the `debugOutputFolder` variable below.<jupyter_code>debugOutputFolder = "/tmp"
tempVar = set_key(envPath, "DEBUG_OUTPUT_FOLDER", debugOutputFolder)<jupyter_output><empty_output><jupyter_text>The following cell will set the name of the media graph file to be used in this sample. We provide a variety of sample media graph files in the **live-video-analytics/MediaGraph** folder. To learn more about media graphs, [read our documentation here](https://docs.microsoft.com/en-us/azure/media-services/live-video-analytics-edge/media-graph-concept).<jupyter_code>topologyFile = "grpcExtension/topology.json"
tempVar = set_key(envPath, "TOPOLOGY_FILE", topologyFile)<jupyter_output><empty_output><jupyter_text>The following cell will extract the name of our sample media graph topology file.<jupyter_code>import json
import os.path

with open(os.path.join("../../../../../../MediaGraph/topologies/", topologyFile)) as f:
    data = json.load(f)

topologyName = data["name"]
tempVar = set_key(envPath, "TOPOLOGY_NAME", topologyName)<jupyter_output><empty_output><jupyter_text>The following cell will set the name of the media graph instance that will be used in later sections. With LVA, you may set more than one topology instance, so be sure to give each instance a unique name.<jupyter_code>graphInstanceName = "Sample-Graph-Instance"
tempVar = set_key(envPath, "GRAPH_INSTANCE_NAME", graphInstanceName)<jupyter_output><empty_output><jupyter_text>The following cell will set the media graph parameters specific to this sample.<jupyter_code># Address of the RTSP camera stream source
rtspUrl = "rtsp://rtspsim:554/media/lots_284.mkv"

# Sensitivity of the motion detector low|medium|high
motionSensitivity = 'medium'

# gRPC connection endpoint URL of the lvaextension module
grpcExtensionAddress = "tcp://lvaextension:44000"

# Image file formats. Supported formats are jpeg, bmp and png
imageEncoding = "jpeg"

# Image Storage Quality. Values below 75 will result in significant decrease in image quality.
imageQuality = "90"

# preserveAspectRatio | pad: YOLOv3 model and its wrapper requires exact this scaling.
imageScaleMode = "pad"

# Be careful with dimensions. YOLOv3 model and its wrapper requires exact this size.
frameWidth = "416"
frameHeight = "416"<jupyter_output><empty_output><jupyter_text>The following cell will create parameters in JSon format to be used while deploying the media graph.<jupyter_code>mediaGraphTopologyParameters = {
          "name": graphInstanceName,
          "properties": {
            "topologyName": topologyName,
            "parameters": [
              {
                "name": "rtspUrl",
                "value": rtspUrl
              },
              {
                "name": "motionSensitivity",
                "value": motionSensitivity
              },
              {
                "name": "grpcExtensionAddress",
                "value": grpcExtensionAddress
              },
              {
                "name": "imageEncoding",
                "value": imageEncoding
              },
              {
                "name": "imageQuality",
                "value": imageQuality
              },
              {
                "name": "imageScaleMode",
                "value": imageScaleMode
              },
              {
                "name": "frameWidth",
                "value": frameWidth
              },
              {
                "name": "frameHeight",
                "value": frameHeight
              }              
            ]
          }
        }

with open("../../../common/.media_graph_topology_parameters.json", "w") as f:
    json.dump(mediaGraphTopologyParameters, f, indent=4)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09269762495568948, 'fraction_numerical': 0.006026231832683446, 'mean_word_length': 3.436320754716981, 'pattern_counts': {'":': 20, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '48979', 'license': 'MIT', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1572, 'n_words': 491, 'path': 'utilities/video-analysis/notebooks/Yolo/yolov4/yolov4-grpc-icpu-onnx/setup_specific_environment.ipynb', 'repo_name': 'fvneerden/live-video-analytics', 'size': '5642'}