def person_detect(camera, date, hour): gate_model_path = 'C:\\Users\\sgudla\\Downloads\\models\\person_gate_model\\frozen_inference_graph.pb' stairs_model_path = 'C:\\Users\\sgudla\\Downloads\\models\\person_stairs_model\\frozen_inference_graph.pb' threshold = 0.9 if "GatePhotos": odapi = DetectorAPI(path_to_ckpt=stairs_model_path) else: odapi = DetectorAPI(path_to_ckpt=gate_model_path)
from shared import * from detector import DetectorAPI from pytz import timezone gate_model_path = '/home/pi/Downloads/person_gate_model/frozen_inference_graph.pb' stairs_model_path = '/home/pi/Downloads/person_stairs_model/frozen_inference_graph.pb' threshold = 0.8 for photo_root in photo_root_dirs: if "StairsPhotos" in photo_root: odapi = DetectorAPI(path_to_ckpt=stairs_model_path) else: odapi = DetectorAPI(path_to_ckpt=gate_model_path) # Runs upto the specified date (not including the date) india = timezone('Asia/Calcutta') today = datetime.datetime.now(india) yday = today-datetime.timedelta(days=1) today_date = today.strftime("%Y-%m-%d") yday_date = yday.strftime("%Y-%m-%d") days = [today_date,yday_date] dt = datetime.datetime.strptime("2019-05-14", "%Y-%m-%d").date() for date_dir in days: if not os.path.exists(os.path.join(photo_root,date_dir)): continue print("Running on :"+os.path.join(photo_root,date_dir)) for hr_dir in get_sub_dirs(os.path.join(photo_root,date_dir)):
parser = argparse.ArgumentParser() parser.add_argument('input_file', type=argparse.FileType('r'), help="Image to be processed") parser.add_argument('inference_graph_file', type=argparse.FileType('r'), help="Inference graph to be used") args = parser.parse_args() model_path = args.inference_graph_file.name img_path = args.input_file.name print("Model={}".format(model_path)) print("Image={}".format(img_path)) odapi = DetectorAPI(path_to_ckpt=model_path) threshold = 0.6 img = cv2.imread(img_path) img = cv2.resize(img, (640, 360)) start_time = time.time() boxes, scores, classes, num = odapi.processFrame(img) label = "" for i in range(len(boxes)): box = boxes[i] # Class 1 represents human if classes[i] == 1 and scores[i] > threshold: label = label + "%d %d %d %d %s\n" % (box[0], box[1], box[2], box[3], str(round(scores[i] * 100, 2))) print("Person found in image '%s': %s" % (img_path, label))
import time import os.path from shared import * from detector import DetectorAPI if not check_hdd(): exit(0) start_time = time.time() now = datetime.datetime.now() lasthour = now - datetime.timedelta(hours=1) date = lasthour.strftime("%Y-%m-%d") model_path = '/home/pi/person_detect_models/latest/frozen_inference_graph.pb' odapi = DetectorAPI(path_to_ckpt=model_path) threshold = 0.6 hour = '%02dhour' % (lasthour.hour) total = 0 for photo_root in photo_root_dirs: cur_dir = os.path.join(photo_root, date, hour) if not os.path.exists(cur_dir): log_message("Directory does not exists: " + cur_dir) continue remove_duplicates(cur_dir) total = total + runPersonDetect(photo_root, date, hour, odapi, threshold) backup_hour(cur_dir) total_time = time.time() - start_time
from gui import Gui from detector import DetectorAPI #define path to model, currently its in the app folder modelPath = 'model3.pb' threshold = 0.3 detector = DetectorAPI(modelPath) gui = Gui(detector)