Skip to content

Instantly share code, notes, and snippets.

View tonyreina's full-sized avatar

Tony Reina tonyreina

View GitHub Profile
@tonyreina
tonyreina / bayes_epidemic_curve.py
Last active October 11, 2025 06:36
Epidemic curve with Bayesian modeling
# 🎬 ANIMATED BAYESIAN LEARNING DEMONSTRATION
# Create a GIF showing how the model evolves as each data point is added
# 🦠 BAYESIAN EPIDEMIC MODELING FOR STUDENTS
# Complete demonstration in a single cell
# Shows uncertainty quantification for public health decision-making
import numpy as np
import matplotlib.pyplot as plt
from scipy.linalg import cho_factor, cho_solve
from scipy.stats import norm
@tonyreina
tonyreina / snake-monster.py
Created August 14, 2025 20:24
Creates an animation of a snake-like monster.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# --- Precompute x and y (Mathematica: x = N@Range[10000]; y = x/235.) ---
x = np.arange(1, 10001, dtype=np.float64)
y = x / 235.0
def pts(t: float) -> np.ndarray:
"""
@tonyreina
tonyreina / build_opencv_with_cuda.sh
Last active August 13, 2024 05:12
Build OpenCV with CUDA and Python
#!/bin/bash
# Downloads and builds OpenCV with NVIDIA CUDA support.
# Builds C++ and Python libraries.
# To use in Python just import cv2
echo -e "Building OpenCV with CUDA support...\n\n"
TEMP_DIR=$(mktemp -d)
import cv2
import numpy as np
from scipy import ndimage
""" Erosion with OpenCV """
def Erosion_Opencv(img, kernel):
cv2.imshow("Input Image", img)
cv2.waitKey(0)
erosion = cv2.erode(img,kernel,iterations = 1)
from tensorflow.keras.utils import Sequence
import numpy as np
class DatasetGenerator(Sequence):
"""
TensorFlow Dataset from Python/NumPy Iterator
"""
def __init__(self, filenames, batch_size=8, crop_dim=[240,240], augment=False, seed=816):
@tonyreina
tonyreina / CLA
Last active February 10, 2021 23:21
Contribution License Agreement
This Contribution License Agreement ("Agreement") is agreed to by the party signing below ("You"), and conveys certain license rights to the Intel Corporation ("Intel") for Your contributions to Intel open source projects. This Agreement is effective as of the latest signature date below.
1. Definitions.
"Code" means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to Intel under this Agreement.
"Project" means any of the projects owned or managed by Intel and offered under a license approved by the Open Source Initiative (www.opensource.org).
"Submit" is the act of uploading, submitting, transmitting, or distributing code or other content to any Project, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of discussing and improving that Project, but excluding communication that is
# !/usr/bin/env python
import tensorflow as tf
from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2_as_graph
from tensorflow.lite.python.util import run_graph_optimizations, get_grappler_config
from pathlib import Path
import argparse
def frozen_keras_graph(model):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@tonyreina
tonyreina / convert.py
Created November 5, 2019 23:30
Summarize TensorFlow Graph for Inputs and Outputs
import argparse
import tensorflow as tf
import os
import sys
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
unlikely_output_types = ['Const', 'Assign', 'NoOp', 'Placeholder', 'Assert']
def dump_for_tensorboard(graph_def: tf.GraphDef, logdir: str):
# !/usr/bin/env python
"""
Copyright (c) 2018 Intel Corporation
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0