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 / vae_model.py
Last active January 14, 2023 02:12
Resnet Variational autoencoder for image reconstruction
import torch
from torch import nn
import torch.nn.functional as F
import abc
import pytorch_ssim
import torchvision.models as models
from torch.autograd import Variable
class AbstractAutoEncoder(nn.Module):
@bmabir17
bmabir17 / convert.py
Last active February 6, 2022 20:54
Converts the mask-rcnn keras model https://github.com/matterport/Mask_RCNN/releases/tag/v2.0 to tflite
import tensorflow as tf
import numpy as np
import mrcnn.model as modellib # https://github.com/matterport/Mask_RCNN/
from mrcnn.config import Config
import keras.backend as keras
PATH_TO_SAVE_FROZEN_PB ="./"
FROZEN_NAME ="saved_model.pb"
@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
//
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]}
)
# 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)
@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