Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Focused on Ambianic.ai

Ivelin Ivanov ivelin

💭
Focused on Ambianic.ai
View GitHub Profile
View Ambianic.ai CLA
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the Apache 2.0 license; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the Apache 2.0 license; or
@ivelin
ivelin / docker-compose.yaml
Last active Jun 10, 2020
Default docker compose configuration for Ambianic Edge
View docker-compose.yaml
version: "3.7"
services:
ambianic-edge:
container_name: ambianic-edge
restart: unless-stopped
privileged: true
image: ambianic/ambianic-edge:latest
network_mode: "host"
volumes:
- /dev/bus/usb:/dev/bus/usb
@ivelin
ivelin / config.yaml
Last active Mar 5, 2020
Example config.yaml for a new Ambianic Edge install
View config.yaml
######################################
# Ambianic main configuration file #
######################################
version: '1.2.4'
# path to the data directory
data_dir: &data_dir ./data
# Set logging level to one of DEBUG, INFO, WARNING, ERROR
logging:
@ivelin
ivelin / good_process_kill.py
Last active Sep 30, 2019
Python good process kill
View good_process_kill.py
def _process_kill(pid, signal=0):
"""Send a signal to a process.
:Returns:
----------
True if the pid is dead
with no signal argument, sends no signal.
"""
@ivelin
ivelin / gist:d3348ead68faf9707071bf9734616a94
Created Aug 21, 2019
frigate conf.yml example with ffmpeg parameters
View gist:d3348ead68faf9707071bf9734616a94
################
# Optional ffmpeg input parameters. Change these only if you are experimenting with ffmpeg parameter optimization.
# Changing these parameters will override the default settings and may corrupt the video capture flow.
################
ffmpeg_input_args:
- -avoid_negative_ts
- make_zero
- -fflags
- nobuffer
- -flags
View test_pcap_eager.py
dataset = pcap_io.PcapDataset(url_filenames, batch=1)
packets_total = 0
for v in dataset:
(packet_timestamp, packet_data) = v
if packets_total == 0:
assert packet_timestamp.numpy()[0] == 1084443427.311224 # we know this is the correct value in the test pcap file
assert len(packet_data.numpy()[0]) == 62 # we know this is the correct packet data buffer length in the test pcap file
packets_total += 1
assert packets_total == 43 # we know this is the correct number of packets in the test pcap file
View pcap_ops.py
"""PcapDataset"""
import tensorflow as tf
from tensorflow_io.core.python.ops import data_ops as data_ops
from tensorflow_io import _load_library
pcap_ops = _load_library('_pcap_ops.so')
class PcapDataset(data_ops.Dataset):
"""A pcap Dataset. Pcap is a popular file format for capturing network packets.
"""
View _init_.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.util.all_util import remove_undocumented
from tensorflow_io.pcap.python.ops.pcap_ops import PcapDataset
_allowed_symbols = [
"PcapDataset",
]
View pcap_input.cc
// read packets from the file up to record_to_read or end of file
while ((*record_read) < record_to_read) {
int64 record_count = 0;
double packet_timestamp;
string packet_data_buffer;
Status status = state.get()->ReadRecord(packet_timestamp, &packet_data_buffer, record_count);
if (!(status.ok() || errors::IsOutOfRange(status))) {
return status;
}
if (record_count > 0) {
View pcap_input.cc
REGISTER_UNARY_VARIANT_DECODE_FUNCTION(PcapInput, "tensorflow::data::PcapInput");
REGISTER_KERNEL_BUILDER(Name("PcapInput").Device(DEVICE_CPU),
FileInputOp<PcapInput>);
REGISTER_KERNEL_BUILDER(Name("PcapDataset").Device(DEVICE_CPU),
FileInputDatasetOp<PcapInput, PcapInputStream>);
You can’t perform that action at this time.