Skip to content

Instantly share code, notes, and snippets.

View mrtj's full-sized avatar

Janos Tolgyesi mrtj

View GitHub Profile
mrtj /
Last active March 28, 2024 04:18
Download a file and stream it directly to an #aws S3 bucket without saving it locally
#!/usr/bin/env python3
import boto3
import requests
import tqdm
from urllib.parse import urlparse
def stream_to_s3(
import functools
def lazy_property(func):
''' Caches the return value of a function, and turns it into a property.
Intended to be used as a function decorator::
>>> class Foo:
>>> @lazy_property
>>> def bar(self):
mrtj /
Last active November 18, 2023 17:51
Python port of GStreamer RTSP Server test-launch.c
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import GLib, Gst, GstRtspServer
import argparse
parser = argparse.ArgumentParser(description='GStreamer RTSP server test-launch')
mrtj /
Last active June 20, 2022 20:56
Example usage of backpack.annotation module
import panoramasdk
from backpack.annotation import (
Point, LabelAnnotation, RectAnnotation, TimestampAnnotation,
class Application(panoramasdk.node):
def __init__(self):
mrtj /
Last active June 20, 2022 20:55
Example usage of backpack.kvs.KVSSkyLine class
import panoramasdk
from backpack.kvs import KVSSkyLine, KVSFileCredentialsHandler
# You might want to read these values from Panorama application parameters
stream_region = 'us-east-1'
stream_name = 'panorama-video'
# The example Dockerfile writes static configuration variables to this file
# If you change the .env file path in the Dockerfile, you should change it also here
DOTENV_PATH = '/panorama/.env'
class Application(panoramasdk.node):
# ...
def process_media(self, stream):
image_data, ratio = self.preprocess(stream.image, self.MODEL_INPUT_SIZE)
inference_results =
{self.MODEL_INPUT_NAME: image_data}, self.MODEL_NODE
self.process_results(inference_results, stream, ratio)
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:
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
"interfaces": [
"name": "interface",
"category": "business_logic",
"asset": "code_asset",
"inputs": [
"name": "video_in",
"type": "media"