Skip to content

Instantly share code, notes, and snippets.

View Shamim-38's full-sized avatar

Shamimul Islam Shamim-38

View GitHub Profile
from google.colab import drive
drive.mount('/content/drive', force_remount=True)
# Importing all necessary libraries
import cv2
import os
# Read the video from specified path
cam = cv2.VideoCapture("Video/Path/h.mp4") #Video path
@Shamim-38
Shamim-38 / split_into_training_gallery-probe.py
Created March 28, 2023 11:17
Data Preprocessing for Authentication/Verification
Pretty good solution. One can resize a video as:
ffmpeg -i AigCblw--hk_000067_000077.mp4 -vf "scale='if(gt(ih,iw),256,trunc(oh*a/2)*2):if(gt(ih,iw),trunc(ow/a/2)*2,256)'" output.mp4
For multiple videos, one can perform (please mkdir a videos_resized folder in prepath ../):
for f in *.mp4 ; do ffmpeg -i "$f" -vf "scale='if(gt(ih,iw),256,trunc(oh*a/2)*2):if(gt(ih,iw),trunc(ow/a/2)*2,256)'" "../videos_resized/$f" ; done
Try to find max in list:
l = [1,2,3,4,4]
num = max(l, key=lambda x:l.count(x)) # num will be 4
the you can get the count of num.
l.count(num) # this wil returns 2
in the other hand as @buddemat said(Here), it is better to:
To reduce the size of your mp4 you have two good choices with FFmpeg:
Experiment with Constant Rate Factor (CRF) settings to find a match between video output size and video quality
Experiment with the set bitrate of your choice and use a 2 pass encode.
Details of both below:
1. Resize using FFmpeg's Constant Rate Factor (CRF) option:
In FFmpeg the CRF settings vary from 0-51 with 0 being lossless and 51 being shockingly poor quality. The default is 23 and you need to find the 'sweet spot' for your particular video of file size and video quality with some experimentation.
@Shamim-38
Shamim-38 / keras_model_continue_training.ipynb
Created September 25, 2022 19:05
Keras_model_Continue_training.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import pandas as pd
eps = np.finfo(float).eps
from numpy import log2 as log
dataset = {'Taste':['Salty','Spicy','Spicy','Spicy','Spicy','Sweet','Salty','Sweet','Spicy','Salty'],
'Temperature':['Hot','Hot','Hot','Cold','Hot','Cold','Cold','Hot','Cold','Hot'],
'Texture':['Soft','Soft','Hard','Hard','Hard','Soft','Soft','Soft','Soft','Hard'],
'Eat':['No','No','Yes','No','Yes','Yes','No','Yes','Yes','Yes']}
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline
from tensorflow.keras.datasets import fashion_mnist
#(x_train, _), (x_test, _) = fashion_mnist.load_data()
import os
#Writer: Md Shamimul Islam
import cv2
import numpy as np
import os
from matplotlib import pyplot as plt
import time
import mediapipe as mp
import glob
Create a new repository on GitHub. You can also add a gitignore file, a readme and a licence if you want
Open Git Bash
Change the current working directory to your local project.
Initialize the local directory as a Git repository.
git init
Add the files in your new local repository. This stages them for the first commit.
git add .
Commit the files that you’ve staged in your local repository.
git commit -m "initial commit"
Copy the https url of your newly created repo