Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

B M Abir bmabir17

🎯
Focusing
View GitHub Profile
View convert_save.py
# 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)
View convert_load.py
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 / index.js
Created Apr 17, 2020
Firebase cloud function for firestore
View index.js
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
//
View convert.py
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 / vae_model.py
Last active Jan 7, 2020
Resnet Variational autoencoder for image reconstruction
View vae_model.py
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):
View hikVisionApi_test.py
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 / webcam_capture.py
Created Feb 2, 2019
ffmpeg webcam campture
View webcam_capture.py
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)
View main.dart
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);