Skip to content

Instantly share code, notes, and snippets.

View bmabir17's full-sized avatar
🎯
Focusing

B M Abir bmabir17

🎯
Focusing
View GitHub Profile
import 'dart:io' as Io;
import 'package:image/image.dart';
void main(){
//Read an image from file
//You can also use other file format like jpeg, webp,TIFF, PSD, GIF
var imageFile = new Io.File('test.png').readAsBytesSync();
//decodeImage will identify the format of the image and
// decode the image accordingly
Image image = decodeImage(imageFile);
@bmabir17
bmabir17 / webcam_capture.py
Created February 2, 2019 19:17
ffmpeg webcam campture
import subprocess as sp
import time
while(True):
sp.call('ffmpeg -f v4l2 -framerate 25 -t 4 -video_size 640x480 -i /dev/video0 ./webcam_output.mp4 -y',shell=True)
print('Video Captured')
time.sleep(1)
from hikvisionapi import Client
import cv2
import numpy as np
cam = Client('http://192.168.1.2','admin','admin123',timeout=1)
cap=cv2.VideoCapture('rtsp://admin:admin123@192.168.1.2:554/main/av_stream')
#response = cam.System.deviceInfo(method='get')
#print(response)
#motion_detection_info = cam.System.Video.inputs.channels[1].motionDetection(method='get')
@bmabir17
bmabir17 / index.js
Created April 17, 2020 21:29
Firebase cloud function for firestore
const functions = require('firebase-functions');
const admin = require('firebase-admin');
// var serviceAccount = require("/home/bmabir/dev/tran-dao-8e837f43806d.json");
admin.initializeApp({
credential: admin.credential.applicationDefault()
});
const db = admin.firestore();
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
# Default Optimization is choosen
converter.optimizations = [tf.lite.Optimize.DEFAULT]
# Convert to TFLite Model
tflite_model = converter.convert()
# Save Model as tflite format
tflite_path = "deeplabv3_mnv2_custom_257.tflite"
tflite_model_size = open(tflite_path, 'wb').write(tflite_model)
MODEL_FILE = "frozen_inference_graph_257.pb"
# Load the TensorFlow model
converter = tf.compat.v1.lite.TFLiteConverter.from_frozen_graph(
graph_def_file = MODEL_FILE,
input_arrays = ['sub_2'], # For the Xception model it needs to be `sub_7`, for MobileNet it would be `sub_2`
output_arrays = ['ResizeBilinear_2'],
input_shapes={'sub_2':[1,257,257,3]}
)
@bmabir17
bmabir17 / .bashrc
Last active May 13, 2021 11:28
Shorten bash path and add time, git_branch info with reference from https://superuser.com/a/1209333/1341976
git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
HOST='\[\033[02;36m\]\h'; HOST=' '$HOST
TIME='\[\033[01;31m\]\t \[\033[01;32m\]'
LOCATION=' \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).$'
BRANCH=' \[\033[00;33m\]$(git_branch)\[\033[00m\] '
PS1=$TIME$BRANCH$USER$HOST$LOCATION
@bmabir17
bmabir17 / DatasetTools.py
Last active July 8, 2021 06:40
Logging Keras Validation Results with WandB
import numpy as np
from PIL import Image
from pathlib import Path
from collections import defaultdict
import keras
# import tensorflow as tf
# from tensorflow.python import keras
# from tensorflow.python.keras import backend as Keras
from tensorflow.keras.utils import Sequence
import logging
@bmabir17
bmabir17 / DatasetTools.py
Last active July 19, 2021 14:20
Transfer Learning Models for Training Classifier
import numpy as np
from PIL import Image
from pathlib import Path
from collections import defaultdict
import keras
from tensorflow.keras.utils import Sequence
import logging
import matplotlib.pyplot as plt
import cv2