Skip to content

Instantly share code, notes, and snippets.

@batu
batu / inferer.cs
Created October 20, 2021 19:25
Inference on Barracuda Loaded ONNX model
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Unity.Barracuda;
using UnityEngine;
using Random = UnityEngine.Random;
public class Inferer : MonoBehaviour, InputHandler
{
down_sized_altair = []
img_data = []
img_shape = down_sized[10].shape
for index, image in enumerate(down_sized[0:10]):
for y in range(img_shape[0]):
for x in range(img_shape[1]):
pixel_color = image[y][x]/255
img_data.append((index, x+.5, img_shape[0]-y-.5, rgb2hex(pixel_color), explore_counts[index]))
down_sized_altair.append(img_data)
@batu
batu / altair_show_image.py
Last active May 3, 2019 22:35
Altair Show Image
img_data = []
img_shape = image.shape
# I am sure there is a less loopy way of doing this.
for y in range(img_shape[0]):
for x in range(img_shape[1]):
pixel_color = image[y][x]
# Add a .5 offset and convert from RGB to Hex.
img_data.append((x +.5, y + .5, rgb2hex(pixel_color)))