Skip to content

Instantly share code, notes, and snippets.

View yptheangel's full-sized avatar
Working from home

Choo Wilson yptheangel

Working from home
View GitHub Profile
package global.skymind.solution.humanactivity;
import org.datavec.api.records.reader.SequenceRecordReader;
import org.datavec.api.records.reader.impl.csv.CSVSequenceRecordReader;
import org.datavec.api.split.NumberedFileInputSplit;
import org.deeplearning4j.api.storage.StatsStorage;
import org.deeplearning4j.arbiter.ComputationGraphSpace;
import org.deeplearning4j.arbiter.conf.updater.AdamSpace;
import org.deeplearning4j.arbiter.layers.LSTMLayerSpace;
import org.deeplearning4j.arbiter.layers.RnnOutputLayerSpace;
@yptheangel
yptheangel / sequenceToOutputLayer.java
Last active August 7, 2019 05:37
Attempt to fix the error given input features and labels as a SequenceRecordReader and having OutputLayer as the last layer
import org.datavec.api.records.reader.RecordReader;
import org.datavec.api.records.reader.SequenceRecordReader;
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
import org.datavec.api.records.reader.impl.csv.CSVSequenceRecordReader;
import org.datavec.api.split.NumberedFileInputSplit;
import org.deeplearning4j.api.storage.StatsStorage;
import org.deeplearning4j.datasets.datavec.RecordReaderMultiDataSetIterator;
import org.deeplearning4j.datasets.datavec.SequenceRecordReaderDataSetIterator;
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
apiVersion: "kubeflow.org/v1"
kind: "TFJob"
metadata:
name: "inception-train-job"
spec:
replicaSpecs:
- replicas: 4
tfReplicaType: WORKER
template:
spec:
@yptheangel
yptheangel / createPV.yaml
Created August 11, 2019 10:04
debugging an example of kubeflow pipeline
kind: PersistentVolume
apiVersion: v1
metadata:
name: mypv
namespace: kubeflow
labels:
type: local
spec:
storageClassName: sata
capacity:
@yptheangel
yptheangel / TinyYoloObjDetectionVideo.java
Created August 27, 2019 08:32
An activity code that streams Camera frames and run Tiny YOLO object detection in real time on Android OS
package com.yptheangel.dl4jandroid.yolo_objdetection;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import com.yptheangel.dl4jandroid.yolo_objdetection.utils.VOCLabelsAndroid;
import static android.os.Environment.getExternalStoragePublicDirectory;
@yptheangel
yptheangel / build.gradle
Created August 27, 2019 08:37
Gradle for DL4J TinyYOLO inference
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.yptheangel.dl4jandroid.yolo_objdetection"
minSdkVersion 24
targetSdkVersion 24
versionCode 1
@yptheangel
yptheangel / JavaTimer.java
Created September 1, 2019 10:40
Use a timer to count the time to complete a function in Java
import java.util.concurrent.TimeUnit;
public class JavaTimer{
public static void main(String []args){
long start_time =System.nanoTime();
//Create a delay of 1 second or 1000milliseconds
try{
Thread.sleep(1000);
import timeit
import time
start_time = timeit.default_timer()
# Using time module to create the delay, you can replce this line with your process
time.sleep(1)
end_time = timeit.default_timer()
elapsed_time = end_time - start_time
# Round the elapsed time to 2 decimal points
print("Elapsed time: {}".format(round(elapsed_time,2)))
@yptheangel
yptheangel / putText_with_background.java
Created October 21, 2019 08:44
draw_text_with_background_opencv
int baseline[]={0};
Size textSize=getTextSize("Hello World", FONT_HERSHEY_DUPLEX, 1,1,baseline);
int textwidth=textSize.get(0);
int textheight=textSize.get(1);
rectangle(yourMat, new Point(x1 + 2, y2 - 2), new Point(x1 + 2+textwidth, y2 - 2-textheight),RGB(255,255,0), FILLED,0,0);
@yptheangel
yptheangel / putText_with_background.java
Last active October 21, 2019 09:20
draw_text_with_background_opencv
int baseline[]={0};
Size textSize=getTextSize("Hello World", FONT_HERSHEY_DUPLEX, 1,1,baseline);
int textwidth=textSize.get(0);
int textheight=textSize.get(1);
rectangle(yourMat, new Point(x1 + 2, y2 - 2), new Point(x1 + 2+textwidth, y2 - 2-textheight),RGB(255,255,0), FILLED,0,0);
putText(yourMat, "Hello World", new Point(x1 + 2, y2 - 2), FONT_HERSHEY_DUPLEX, 1, RGB(0,0,0));