Skip to content

Instantly share code, notes, and snippets.

View backnotprop's full-sized avatar
📟
E.Alderson

Michael Ramos backnotprop

📟
E.Alderson
View GitHub Profile
# tfcoreml src
# file1 : _interpret_shapes.py
#
# in the _SHAPE_TRANSLATOR_REGISTRY we need to add the Pow operation
_SHAPE_TRANSLATOR_REGISTRY = {
... previous keys ...
# add this:
'Pow': _identity,
}
import tfcoreml as tf_converter
tf_converter.convert(tf_model_path = 'output_graph.pb',
mlmodel_path = 'model_name.mlmodel',
output_feature_names = ['add_37:0'],
## Note found this after running a conversion the first time
image_input_names = ['img_placeholder__0'])
import coremltools
def convert_multiarray_output_to_image(spec, feature_name, is_bgr=False):
"""
Convert an output multiarray to be represented as an image
This will modify the Model_pb spec passed in.
Example:
model = coremltools.models.MLModel('MyNeuralNetwork.mlmodel')
spec = model.get_spec()
convert_multiarray_output_to_image(spec,'imageOutput',is_bgr=False)
private let models = [
wave().model,
udnie().model,
rain_princess().model,
la_muse().model
]
//
// StyleTransferInput.swift
// StyleTransfer
//
import CoreML
class StyleTransferInput : MLFeatureProvider {
var input: CVPixelBuffer
private func stylizeImage(cgImage: CGImage, model: MLModel) -> CGImage {
// size can change here if you want, remember to run right sizes in the fst evaluating script
let input = StyleTransferInput(input: pixelBuffer(cgImage: cgImage, width: 883, height: 720))
// model.prediction will run the style model on input image
let outFeatures = try! model.prediction(from: input)
// we get the image buffer after
let output = outFeatures.featureValue(for: "add_37__0")!.imageBufferValue!

Keybase proof

I hereby claim:

  • I am mdramos on github.
  • I am rambossa (https://keybase.io/rambossa) on keybase.
  • I have a public key whose fingerprint is 50B7 2B40 2491 3DB2 279E 4243 D11F 7D44 0A73 27C6

To claim this, I am signing this object:

Sun Jul 15 17:59:46 UTC 2018
@backnotprop
backnotprop / bear_survival.md
Last active July 21, 2019 13:19
Can the bear population survive

Looking for a solution to my below game problem. I believe it to require some sort of reinforcement learning, dynamic programming, or probabilistic programming solution, but am unsure... This is my original problem, and is part of an initiative to create "unique and challenging problem that you're able to conceptualize and then solve. 3 Judging criteria: uniqueness, complexity, and solution (no particular weighting and scoring may favor uniqueness/challenge over solution"

Inspirations: Conway's Game of Life, DeepMind's Starcraft Challenge, deep Q-learning, probabilistic programming

BEAR SURVIVAL

A bear is preparing for hibernation. A bear must reach life-strength 1000 in order to rest & survive the winter. A bear starts off at a health of 500. A bear explores an environment of magic berries. A bear makes a move (chosen randomly with no optional direction) and comes across a berry each time. There are 100 different types of berries that all appear across the wilderness equally and

@backnotprop
backnotprop / cpu_manager.sh
Created May 20, 2020 00:42 — forked from yanniszark/cpu_manager.sh
GKE CPU Pinning Script - Run this as a DaemonSet
#!/bin/bash
HOSTFS="/mnt/hostfs"
function sleep_forever() {
while true; do sleep 100; done
}
function setup_kubectl() {
# Setup kubectl