This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3.11.7 Conda build with Tkinter 8.6.13 - Should fix MacOS Sonoma unresponsive-mouse-click issues. | |
# | |
# Modified from https://gist.github.com/space-medicine-lab/17ebe2dee2cc9c26c8907db85bfa220e | |
# | |
# | |
# This file may be used to create an environment using: | |
# $ conda create --name <env> --file <this file> | |
# platform: osx-arm64 | |
@EXPLICIT | |
https://repo.anaconda.com/pkgs/main/osx-arm64/blas-1.0-openblas.conda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Peter O'Connor | |
# This script starts with a pyinstaller spec file, builds a macOS app, | |
# codesigns it, notarizes it, staples the notarization ticket, and zips it up. | |
# Full Guide at: https://sites.google.com/site/petesjunkyard/how-to-turn-your-python-program-into-a-working-macos-app | |
# | |
# Before using: | |
# 1) You should have a python app with a main script. | |
# 2) Become apple developer - See guide https://sites.google.com/site/petesjunkyard/how-to-turn-your-python-program-into-a-working-macos-app | |
# 3) Install pyinstaller with | |
# pip install pyinstaller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shutil | |
import tempfile | |
from dataclasses import dataclass | |
from typing import Optional, Callable, Any, Mapping | |
import os | |
import numpy as np | |
import tensorflow as tf | |
def save_signatures_to_tflite_model( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import itertools | |
import os | |
from collections import OrderedDict | |
from dataclasses import dataclass | |
from typing import Optional, TypeVar, Generic, Hashable, Any | |
from typing import Tuple, Iterator | |
import av | |
import cv2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
def tf_mask_to_boxes(mask, insert_fake_first_box: bool = False): | |
""" | |
Convert a boolean mask to a series of bounding boxes around each segment. | |
Warning: VERY SLOW (slower than pure python version of same algorithm) | |
:param mask: A (HxW) boolean mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from typing import Optional | |
import cv2 | |
import numpy as np | |
import tensorflow as tf | |
def tf_box_sum_image_from_padded_image(padded_image, width: int): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
def warp_image_with_heatmap(src_image: 'BGRImageArray', heatmap: 'HeatMapArray') -> 'BGRImageArray': | |
""" Rough draft of warping an image with a heatmap. | |
We compute a set of "resampled pixel locations" and then use cv2.remap to resample the image from these points. | |
Think of heatmap as representing a grid of point masses. | |
Each heatmap point "pulls" each resampled-pixel-point away from its original location. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, Tuple, Sequence | |
import cv2 | |
def draw_bboxes_on_image( | |
image, # A (height, width, 3) unit8 numpy array representing an image | |
return_relative=False, # True to return box coorinates relative to width/height of image so they will be in [0, 1] interval | |
window_name='Draw Your Bounding Box', # What to call the window | |
display_color=(0, 0, 255), # Colour of the displayed box | |
display_thickness=2 # Thickness of the displayed box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import sys | |
from argparse import ArgumentParser | |
from datetime import datetime | |
from typing import Optional, Sequence | |
def modified_timestamp_to_filename(timestamp: float) -> str: | |
return datetime.fromtimestamp(timestamp).strftime('dji_%Y-%m-%d_%H-%M-%S') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><script type="math/tex; mode=display" id="MathJax-Element-1"> | |
\newcommand{\pderiv}[2]{\frac{\partial #1}{\partial #2}} | |
\newcommand{\lderiv}[1]{\frac{\partial \mathcal L}{\partial #1}} | |
\newcommand{\argmax}[1]{\underset{#1}{\operatorname{argmax}}} | |
\newcommand{\argmin}[1]{\underset{#1}{\operatorname{argmin}}} | |
\newcommand{\switch}[3]{\begin{cases} #2 & \text{if } {#1} \\ #3 &\text{otherwise}\end{cases}} | |
\newcommand{\blue}[1]{\color{blue}{#1}} | |
\newcommand{\red}[1]{\color{red}{#1}} | |
\newcommand{\overlabel}[2]{\overset{#1}{\overline{#2}}} | |
\newcommand{\loss}[0]{\mathcal L} |
NewerOlder