Skip to content

Instantly share code, notes, and snippets.

View aliyevorkhan's full-sized avatar
🌍
Working from Earth

Orkhan ALIYEV aliyevorkhan

🌍
Working from Earth
View GitHub Profile
import os
import datetime
from time import sleep
for file in os.listdir(os.getcwd()):
if file.endswith('.jpg'):
os.rename(file, "img_"+datetime.datetime.now().strftime("%Y%m%d-%H%M%S%f")+'.jpg')
sleep(0.05)
import os
for file in os.listdir(os.getcwd()):
if file.endswith('.txt'):
os.remove(file)
import cv2
cap=cv2.VideoCapture("video.mp4")
fps = cap.get(cv2.CAP_PROP_FPS)
print(fps)
import cv2
path = '/home/orkhan/Desktop/train/'
cap = cv2.VideoCapture('video.mp4')
i = 0
counter = 0
while cap.isOpened():
ret, frame = cap.read()
if not ret:
import cv2
import glob, errno
# Replace mydir with the directory you want
mydir = 'Train1/'
#check if directory exist, if not create it
try:
os.makedirs(mydir)
except OSError as e:
import os
from PIL import Image
def has_transparency(img):
if img.mode == "P":
transparent = img.info.get("transparency", -1)
for _, index in img.getcolors():
if index == transparent:
return True
elif img.mode == "RGBA":
import os
import cv2
src_path = os.path.abspath(os.path.join(os.getcwd(), "bolu_tunnel_nvr"))
print(src_path)
ch1_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch1"))
ch2_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch2"))
print(ch1_dst_path)
import os
import cv2
src_path = os.path.abspath(os.path.join(os.getcwd(), "bolu_tunnel_nvr"))
print(src_path)
ch1_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch1"))
ch2_dst_path = os.path.abspath(os.path.join(os.getcwd(), "ch2"))
print(ch1_dst_path)
import math
BATCH_SIZE=32
TRAINING_SIZE = 40000
# We take the ceiling because we do not drop the remainder of the batch
compute_steps_per_epoch = lambda x: int(math.ceil(1. * x / BATCH_SIZE))
steps_per_epoch = compute_steps_per_epoch(TRAINING_SIZE)
import glob
import sys
import os
lbls = []
frames = []
if_lbl_exists = False
for lbl in glob.glob(str(sys.argv[1])+'/*.txt'):
lbls.append(lbl.split('/')[1].split('.')[0])