Skip to content

Instantly share code, notes, and snippets.

View Ngugi1's full-sized avatar

Ngugi Ndung'u Ngugi1

  • Vrije Universiteit Brussel, Belgium
  • Brussels, Belgium
  • X @samngugi_
View GitHub Profile
@Ngugi1
Ngugi1 / price-predictor.js
Created November 15, 2023 14:02
price-predictor
// import * as tf from "@tensorflow/tfjs-node";
import * as tf from "@tensorflow/tfjs";
// Model architecture
export function pricePredictionModel() {
// Clean all variable stored in the engine - otherwise variable already registered error will occour
// tf.disposeVariables()
// Apartment size input
const sizeInput = tf.input({shape: [1], name: 'size'});
const denseSize = tf.layers.dense({units: 2, name: 'denseSize1'}).apply(sizeInput);
@Ngugi1
Ngugi1 / quality-of-stay.js
Created July 20, 2023 11:59
TensorflowJs implementation of quality-of-stay neural network.
export function qualityOfStay() {
// Clean all variable stored in the engine - otherwise variable already registered error will occour
// tf.disposeVariables()
// let inputs = ['size', 'latitude', 'longitude', ]
const sizeInput = tf.input({shape: [1], name: 'size'});
const denseSize = tf.layers.dense({units: 2, name: 'denseSize'}).apply(sizeInput);
// latitude input
const latitude = tf.input({shape: [1], name: 'latitude'});
const denseLatitude = tf.layers.dense({units: 2, name: 'denseLatitude'}).apply(latitude);
@Ngugi1
Ngugi1 / index.html
Created July 12, 2022 12:49
MediaPipe - Face Detection
<div class="container">
<video class="input_video"></video>
<div class="canvas-container">
<canvas class="output_canvas" width="1280px" height="720px">
</canvas>
</div>
<div class="loading">
<div class="spinner"></div>
<div class="message">
Loading
// How to run this code
// 1. Connect the Ardurino UNO to the JETSON NANO via USB Cable
// 2. Connect the step motor driver to pins 8-11 on the Ardurino UNO
// 3. Connect the step motor to the motor driver
// 4. Supply power to the motor driver by connecting it to the 5v and ground pins on the ardurino
// 5. Connect the step swith to the pin 2 of the ardurino and the other pin to GND
// 6. Install Ardurino studio on the JETSON NANO
// 7. Create a new file and copy this code to the newly created file
// 8. Deploy this code to the ardurino UNO
// 9. To simulate a closed BIN, close the circuit using the step switch
# This code is based on work from this website - https://www.pyimagesearch.com/2018/03/19/reading-#barcodes-with-python-and-openmv/ - and modified to fit our purpose
# ## How to run this project
# Ensure that you `python3 installed`
# Make sure that all these dependencies are installed on the JETSON NANO which is running linux using the commands provided below.
# 1. `sudo apt-get install libzbar0` - zbar library is used together with openCV to facilitate reading of barcodes
# 2. Install python module `pyzbar` using command `pip install pyzbar`
# 3. Install python module `imutils` that is used to ease the processing of images using command `pip install imutils`
@Ngugi1
Ngugi1 / sbin
Created December 15, 2019 11:43
#include <Stepper.h>
// Stop switch
int stepswitch = 2;
// Motor
const int stepsPerRevolution = 480; // change this to fit the number of steps per revolution
int motorSpeed = 100;
// initialize the stepper library on pins 8 through 11:
int stepCount = 0; // number of steps the motor has taken
int motorPin8 = 8;
#include <Stepper.h>
// Stop switch
int stepswitch = 2;
// Motor
const int stepsPerRevolution = 480; // change this to fit the number of steps per revolution
int motorSpeed = 100;
// initialize the stepper library on pins 8 through 11:
int stepCount = 0; // number of steps the motor has taken
int motorPin8 = 8;
int Lswitch = 2;
int led = 13;
int flag = 0;
void setup()
{
Serial.begin(9600);
pinMode(Lswitch, INPUT);
pinMode(led, OUTPUT);
@Ngugi1
Ngugi1 / ad.r
Created December 13, 2019 19:24
/*
Stepper Motor Control - speed control
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
A potentiometer is connected to analog input 0.
The motor will rotate in a clockwise direction. The higher the potentiometer value,
the faster the motor speed. Because setSpeed() sets the delay between steps,
from serial import Serial
channel = serial.Serial('/dev/cu.usbserial-1420',9600)
def led_on():
channel.write('1')
def led_off():
channel.write('0')
led_on()