This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
physical_devices = tf.config.experimental.list_physical_devices('GPU') | |
if len(physical_devices) > 0: | |
tf.config.experimental.set_memory_growth(physical_devices[0], True) | |
from absl import app, flags, logging | |
from absl.flags import FLAGS | |
import core.utils as utils | |
from core.yolov4 import filter_boxes | |
from tensorflow.python.saved_model import tag_constants | |
from PIL import Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division, print_function | |
# coding=utf-8 | |
import sys | |
import os | |
import glob | |
import re, glob, os,cv2 | |
import numpy as np | |
import pandas as pd | |
import detect_object | |
from shutil import copyfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, random, shutil | |
import numpy as np | |
import pandas as pd | |
import PIL | |
#import keras | |
import itertools | |
from PIL import Image | |
import tensorflow as tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datagen = ImageDataGenerator(rescale=1.0/255.0) | |
train_path = 'Your Image Folder Path' | |
train_batches = datagen.flow_from_directory(train_path, target_size=(200,200), classes=classes_required, batch_size=batch_size_train) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model=Sequential() | |
model.add(Conv2D(16,kernel_size=(3,3), activation="relu" ,input_shape=IMAGE_SIZE + [3], padding='same')) | |
model.add(Conv2D(32, kernel_size=(3,3), activation="relu",padding='same')) | |
model.add(BatchNormalization()) | |
model.add(MaxPooling2D(pool_size=(2,2))) | |
model.add(Dropout(0.30)) | |
model.add(Conv2D(64, kernel_size=(3,3), activation="relu",padding='same')) | |
#model.add(BatchNormalization()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_image=cv2.imread("IMAGE_PATH") | |
test_image = np.expand_dims(test_image, axis=0) | |
out=np.argmax(model_loaded.predict(test_image)) | |
Ans=np.where(out==0, "Middle", | |
(np.where(out==1,"Old", | |
"Young"))).item() | |
print(Ans+" age person.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.colab import drive | |
drive.mount('/content/gdrive') | |
!ln -s /content/gdrive/My\ Drive/ /mydrive | |
!ls /mydrive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!git clone https://github.com/AlexeyAB/darknet | |
# verify CUDA | |
!/usr/local/cuda/bin/nvcc --version | |
# change makefile to have GPU and OPENCV enabled | |
%cd darknet | |
!sed -i 's/OPENCV=0/OPENCV=1/' Makefile | |
!sed -i 's/GPU=0/GPU=1/' Makefile | |
!sed -i 's/CUDNN=0/CUDNN=1/' Makefile | |
!sed -i 's/CUDNN_HALF=0/CUDNN_HALF=1/' Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!sed -i 's/batch=1/batch=64/' cfg/yolov4.cfg | |
!sed -i 's/subdivisions=1/subdivisions=16/' cfg/yolov4.cfg | |
!sed -i 's/max_batches = 500500/max_batches = 6000/' cfg/yolov4.cfg | |
!sed -i '968 s@classes=80@classes=1@' cfg/yolov4.cfg | |
!sed -i '1056 s@classes=80@classes=1@' cfg/yolov4.cfg | |
!sed -i '1144 s@classes=80@classes=1@' cfg/yolov4.cfg | |
!sed -i '961 s@filters=255@filters=18@' cfg/yolov4.cfg . | |
!sed -i '1049 s@filters=255@filters=18@' cfg/yolov4.cfg | |
!sed -i '1137 s@filters=255@filters=18@' cfg/yolov4.cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!echo "Glasses" > data/obj.names | |
!echo -e 'classes= 1\ntrain = data/train.txt\nvalid = data/test.txt\nnames = data/obj.names\nbackup = /mydrive/yolov4_v1' > data/obj.data | |
!mkdir data/obj |
OlderNewer