Skip to content

Instantly share code, notes, and snippets.

@cheadrian
cheadrian / _utils.py
Last active May 12, 2021 14:38
Patches for TorchVision 0.9.1 to add fcn_resnet18, fcn_resnet34, fcn_mobilenetv2, fcn_mobilenetv3_large, fcn_mobilenetv3_small and compatible ONNX conversion for TensorRT acceleration. Jetson Nano, Jetson Platform. Replace files in segmentation folder of torchvision package, example: "/usr/local/lib/python3.7/dist-packages/torchvision/models/seg…
from collections import OrderedDict
from torch import nn
from torch.nn import functional as F
class _SimpleSegmentationModel(nn.Module):
__constants__ = ['aux_classifier']
def __init__(self, backbone, classifier, aux_classifier=None, export_onnx=False):
@cheadrian
cheadrian / webhook_google_ads_form_functions.php
Last active January 18, 2024 10:33
Webhook for Google Ads Lead Form extension using WordPress and WP Webhooks plugin and send data to email
/*
* Forward data received by webhook from Google Ads Form Extension
* to selected email
* Details at:
* https://che-adrian.medium.com/create-a-webhook-for-google-ads-lead-form-extension-using-wordpress-and-wp-webhooks-plugin-and-cd2a3c7fb1c3
*/
add_filter( 'wpwhpro/run/actions/custom_action/return_args', 'wpwh_ads_email', 10, 3 );
function wpwh_ads_email( $return_args, $identifier, $response_body ){
//Email where you receive the data
$to = "[email protected]";
@cheadrian
cheadrian / Youtube_Livestream_Parts_download.py
Last active August 13, 2024 16:03
Download Youtube Live streamed video from the start or selected time
#With the help of this script you can download parts from the Youtube Video that is live streamed, from start of the stream till the end
import urllib.request
import os
#E.G: "https://r4---sn-gqn-p5ns.googlevideo.com/videoplayback?expire=1603041842& ..... 2.20201016.02.00&sq="
#The sound link should contain: &mime=audio in it.
#Here's an example from NASA LIVE:
#VIDEO: https://r5---sn-gqn-p5ns.googlevideo.com/videoplayback?expire=1603165657&ei=eQmOX8TeFtS07gO1xLWwDA&ip=79.115.11.159&id=DDU-rZs-Ic4.1&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160&source=yt_live_broadcast&requiressl=yes&mh=PU&mm=44%2C29&mn=sn-gqn-p5ns%2Csn-c0q7lnsl&ms=lva%2Crdu&mv=m&mvi=5&pl=20&initcwndbps=1350000&vprv=1&live=1&hang=1&noclen=1&mime=video%2Fmp4&gir=yes&mt=1603143920&fvip=5&keepalive=yes&fexp=23915654&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Clive%2Chang%2Cnoclen%2Cmime%2Cgir&sig=AOq0QJ8wRQIgQMnxy1Yk3HLTpqbOGmjZYH1CXCTNx6u6PgngAVGi4EQCIQDWyaye-u_KGyVQ0HRUsyKVaAzyXbmzDqOGVGpIyP7VtA%3D%3D&lspa
@cheadrian
cheadrian / export_inference_graph.py
Last active October 12, 2020 14:32
TypeError: export_inference_graph() got an unexpected keyword argument 'use_side_inputs'
#Note: this solution dosen't guarantee that your network will work as expected after you convert with this,
#because it wasn't tested
#enought
#Environement: tensorflow 1.14.0
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@cheadrian
cheadrian / camera_demo.py
Created December 28, 2019 17:52
SSD lufficc OpenCV WebCam Demo
import glob
import os
import time
import torch
from PIL import Image
from vizer.draw import draw_boxes
import cv2