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 bitnami/pytorch:latest | |
# Use Ubuntu as base image because Debian doesn't have g++-11, required by robotpy | |
FROM anibali/pytorch:2.0.1-cuda11.8 | |
USER root | |
# Update the system and install basic dev packages | |
RUN apt-get update && apt-get install -y binutils gcc g++ make git wget libicu-dev gradle && \ | |
apt install -y openjdk-11-jdk vim software-properties-common gnupg | |
# Install additional Python packages |
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 robotpy_apriltag | |
from wpimath.geometry import Transform3d | |
import math | |
# This function is called once to initialize the apriltag detector and the pose estimator | |
def get_apriltag_detector_and_estimator(frame_size): | |
detector = robotpy_apriltag.AprilTagDetector() | |
# FRC 2023 uses tag16h5 (game manual 5.9.2) | |
assert detector.addFamily("tag16h5") |
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 numpy as np | |
rs = np.array([ [1,1], [2, 11], [3, 77], [4, 111], [5, 74], [6, 20], [7.25, 6]]) | |
vs = rs.take(indices = 0, axis=1) | |
ns = rs.take(indices = 1, axis=1) | |
mean = np.average(vs, weights = ns) | |
sd = np.sqrt(np.average((vs - mean)**2, weights=ns)) | |
(mean, sd) |
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
# Update of the Dockerfile at https://towardsdatascience.com/detectron2-the-basic-end-to-end-tutorial-5ac90e2f90e3 | |
FROM python:3.8-slim-buster | |
RUN apt-get update -y | |
# gcc compiler and opencv prerequisites | |
RUN apt-get -y install nano git build-essential libglib2.0-0 libsm6 libxext6 libxrender-dev | |
RUN apt-get install -y python3-opencv | |
# Detectron2 prerequisites |
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 nltk | |
nltk.download('words') | |
from nltk.corpus import words | |
tetrawords = set(w for w in words.words() if len(w) == 4) | |
from constraint import * | |
wordladder = Problem() | |
for v in ['b','c','d','e','f','g','h'] : | |
wordladder.addVariable(v, Domain(tetrawords)) |
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
on: push | |
name: Inline Python Action | |
jobs: | |
my-job: | |
name: My job | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
fetch-depth: 1 |
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
faceContainingImage.Image = UIImage.FromFile("docs.jpg"); | |
//Put it on the screen | |
View.AddSubview(faceContainingImage); | |
faceContainingImage.TranslatesAutoresizingMaskIntoConstraints = false; | |
var dpConstraints = new[] | |
{ | |
faceContainingImage.LeadingAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.LeadingAnchor), | |
faceContainingImage.TrailingAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TrailingAnchor), | |
faceContainingImage.TopAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TopAnchor, 40.0f), |
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
Video Capture | |
previewLayer = new AVCaptureVideoPreviewLayer(captureSession); | |
//previewLayer.VideoGravity = AVLayerVideoGravity.ResizeAspectFill; | |
previewView.Layer.AddSublayer(previewLayer); | |
previewView.TranslatesAutoresizingMaskIntoConstraints = false; | |
var previewConstraints = new[] | |
{ | |
previewView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor), | |
previewView.RightAnchor.ConstraintEqualTo(View.RightAnchor), |
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
let innerXml (node : XNode ) = | |
use rdr = node.CreateReader() | |
rdr.MoveToContent() |> ignore | |
rdr.ReadInnerXml() |
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 numpy as np | |
from keras.models import Sequential | |
from keras.layers.core import Activation, Dense | |
from keras.optimizers import SGD | |
# Allocate the input and output arrays | |
X = np.zeros((4, 2), dtype='uint8') | |
y = np.zeros(4, dtype='uint8') | |
# Training data X[i] -> Y[i] |
NewerOlder