Skip to content

Instantly share code, notes, and snippets.

Avatar

Navarasu navarasu

View GitHub Profile
View tps_color_warping.py
import numpy as np
def TPS_color_correction(input_color,actual_color,reference):
NPs = actual.shape[0]
NPg = reference.shape[0]
Xp = actual[:, 0].conj().transpose()
Yp = actual[:, 1].conj().transpose()
Zp = actual[:, 2].conj().transpose()
Xg = reference[:, 0].conj().transpose()
Yg = reference[:, 1].conj().transpose()
@navarasu
navarasu / utils.py
Last active Oct 13, 2019
Utils for training and prediction
View utils.py
import numpy as np
import boto3
import os
import joblib
def getModel():
bucket=os.getenv("BUCKET_NAME")
S3 = boto3.client('s3')
model_file=os.getenv("MODEL_FILE_NAME")
response = S3.download_file(bucket,model_file,model_file)
@navarasu
navarasu / preprocess.py
Last active Oct 13, 2019
Pre process training data
View preprocess.py
#Prepare event matrix
input_products = sorted(PRODUCTS[PRODUCTS !='Product A'])
event_matrix=generate_event_matrix_index(processed_data,input_products)
x_train_temp=x_train.apply(lambda x : pd.Series(util.encode_events(event_matrix,x[input_products].dropna().items())) ,axis=1)
x_train=x_train_temp.join(x_train[['cus_type','cus_point']])
#Preprocess categorial data
cus_type = CategoricalDtype(categories=processed_data['cus_type'].unique(), ordered=True)
x_train['cus_type']=x_train['cus_type'].astype(cus_type)
x_train=pd.get_dummies(x_train,prefix='cus')
@navarasu
navarasu / object_detector.dart
Created Mar 4, 2019
object_detector for TF Lite object detection
View object_detector.dart
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'package:flutter/services.dart';
class ObjectDetecter extends ValueNotifier<List> {
ObjectDetecter._() : super(null);
static CameraController _controller;
static bool _isDetecting = false;
@navarasu
navarasu / MainActivity.java
Created Mar 4, 2019
MainActivity java for TF Lite object detection
View MainActivity.java
package francium.tech.objectdetector;
import android.content.res.AssetFileDescriptor;
import android.os.Bundle;
import android.renderscript.RenderScript;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;
@navarasu
navarasu / YoloDetector.java
Created Mar 4, 2019
YoloDetector for TF Lite object detection
View YoloDetector.java
package francium.tech.objectdetector;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.SystemClock;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicYuvToRGB;
@navarasu
navarasu / main.dart
Last active Apr 23, 2019
Main Dart for TF Lite object detection
View main.dart
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:camera/camera.dart';
import 'package:object_detector/object_detector.dart';
List<CameraDescription> cameras;
var labels, colors;
@navarasu
navarasu / MainActivity.java
Last active Mar 4, 2019
MainActivity for Loading TF Lite assets example
View MainActivity.java
package francium.tech.objectdetector;
import android.content.res.AssetFileDescriptor;
import android.os.Bundle;
import android.renderscript.RenderScript;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Map;
@navarasu
navarasu / YoloDetector.java
Last active Nov 13, 2019
YoloDetector for Loading TF Lite assets example
View YoloDetector.java
package francium.tech.objectdetector;
import android.renderscript.RenderScript;
import android.util.Log;
import org.json.JSONException;
import org.tensorflow.lite.Interpreter;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.List;
@navarasu
navarasu / main.dart
Last active Mar 4, 2019
Main Dart for Loading TF Lite assets example
View main.dart
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:camera/camera.dart';
List<CameraDescription> cameras;
var labels, colors;
Future<void> main() async {