Skip to content

Instantly share code, notes, and snippets.

Avatar

Janos Tolgyesi mrtj

View GitHub Profile
View panorama-process-media-fix.py
class Application(panoramasdk.node):
# ...
def process_media(self, stream):
image_data, ratio = self.preprocess(stream.image, self.MODEL_INPUT_SIZE)
inference_results = self.call(
{self.MODEL_INPUT_NAME: image_data}, self.MODEL_NODE
)
self.process_results(inference_results, stream, ratio)
View panorama-yolox-postprocess.py
from yolox_postprocess import demo_postprocess, multiclass_nms
class Application(panoramasdk.node):
# ...
def process_results(self, inference_results, stream, ratio):
media_height, media_width, _ = stream.image.shape
media_scale = np.asarray([media_width, media_height, media_width, media_height])
for output in inference_results:
View panorama-yolox-preprocess.py
import cv2
class Application(panoramasdk.node):
# ...
def preprocess(self, img, input_size, swap=(2, 0, 1)):
if len(img.shape) == 3:
padded_img = np.ones((input_size[0], input_size[1], 3), dtype=np.uint8) * 114
else:
View panorama-application-package-fix.json
"interfaces": [
{
"name": "interface",
"category": "business_logic",
"asset": "code_asset",
"inputs": [
{
"name": "video_in",
"type": "media"
},
View panorama-code-node-fix.json
{
"name": "code_node",
"interface": "${AWS_ACCOUNT_ID}::application_logic.interface",
"overridable": false,
"launch": "onAppStart"
}
View panorama-build-container.sh
panorama-cli build-container \
--container-asset-name code \
--package-path packages/${AWS_ACCOUNT_ID}-application_logic-1.0
View panorama-application-descriptor.json
{
"runtimeDescriptor": {
"envelopeVersion": "2021-01-01",
"entry": {
"path": "python3",
"name": "/panorama/application.py"
}
}
}
View panorama-application-main.py
def main():
logger = get_logger(level=logging.DEBUG)
try:
logger.info('INITIALIZING APPLICATION')
app = Application(logger)
logger.info('PROCESSING STREAMS')
# video processing loop:
while True:
app.process_streams()
except:
View panorama-application-stub.py
import panoramasdk
import numpy as np
class Application(panoramasdk.node):
def __init__(self, logger):
super().__init__()
self.logger = logger
self.threshold = 0.
self.MODEL_NODE = 'model_node'
self.MODEL_INPUT_NAME = 'images'