This file contains hidden or 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
| def residual_block(input_layer, input_channel, filter_num1, filter_num2, activate_type='leaky'): | |
| short_cut = input_layer | |
| conv = convolutional(input_layer, filters_shape=(1, 1, input_channel, filter_num1), activate_type=activate_type) | |
| conv = convolutional(conv , filters_shape=(3, 3, filter_num1, filter_num2), activate_type=activate_type) | |
| residual_output = short_cut + conv | |
| return residual_output | |
| def cspdarknet53(input_data): | |
| input_data = convolutional(input_data, (3, 3, 3, 32), activate_type="mish") |
This file contains hidden or 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 | |
| from yolov3.yolov4 import Create_Yolo | |
| from yolov3.utils import load_yolo_weights | |
| from yolov3.configs import * | |
| if YOLO_TYPE == "yolov4": | |
| Darknet_weights = YOLO_V4_TINY_WEIGHTS if TRAIN_YOLO_TINY else YOLO_V4_WEIGHTS | |
| if YOLO_TYPE == "yolov3": | |
| Darknet_weights = YOLO_V3_TINY_WEIGHTS if TRAIN_YOLO_TINY else YOLO_V3_WEIGHTS |
This file contains hidden or 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 | |
| import numpy as np | |
| 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 yolov3.configs import * | |
| from tensorflow.python.compiler.tensorrt import trt_convert as trt | |
| def calibration_input(): | |
| for i in range(100): |
This file contains hidden or 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 multiprocessing import Process, Pipe | |
| import time | |
| import numpy as np | |
| def send_to_pipe(q, mylist): | |
| # function to put elements into Pipe | |
| for num in mylist: | |
| q.send(np.random.random((416, 416, 3))) | |
| def pick_from_pipe(q, mylist): |
This file contains hidden or 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 multiprocessing import Process, Pipe | |
| import time | |
| def send_to_pipe(q, mylist): | |
| # function to put elements into Pipe | |
| for num in mylist: | |
| q.send(num) | |
| def pick_from_pipe(q, mylist): | |
| # function to print pipe elements |
This file contains hidden or 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 multiprocessing import Process, Queue | |
| import time | |
| import numpy as np | |
| def send_to_queue(q, mylist): | |
| # function to put elements into Queue | |
| for num in mylist: | |
| q.put(np.random.random((416, 416, 3))) | |
| def pick_from_queue(q, mylist): |
This file contains hidden or 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 multiprocessing import Process, Queue | |
| import time | |
| def send_to_queue(q, mylist): | |
| # function to put elements into Queue | |
| for num in mylist: | |
| q.put(num) | |
| def pick_from_queue(q, mylist): | |
| # function to print queue elements |
This file contains hidden or 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
| def Predict_bbox_mp(Frames_data, Predicted_data, Processing_times): | |
| gpus = tf.config.experimental.list_physical_devices('GPU') | |
| if len(gpus) > 0: | |
| try: tf.config.experimental.set_memory_growth(gpus[0], True) | |
| except RuntimeError: print("RuntimeError in tf.config.experimental.list_physical_devices('GPU')") | |
| Yolo = Load_Yolo_model() | |
| times = [] | |
| while True: | |
| if Frames_data.qsize()>0: | |
| image_data = Frames_data.get() |
This file contains hidden or 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 multiprocessing import Process, Queue, Pipe | |
| import cv2 | |
| import time | |
| import random | |
| import colorsys | |
| import numpy as np | |
| import tensorflow as tf | |
| from yolov3.configs import * | |
| from yolov3.yolov4 import * | |
| from tensorflow.python.saved_model import tag_constants |
This file contains hidden or 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
| offset = 30 | |
| sct = mss.mss() | |
| yolo = Load_Yolo_model() | |
| while True: | |
| img = np.array(sct.grab({"top": 87-offset, "left": 1920, "width": 1280, "height": 720, "mon": -1})) | |
| img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB) | |
| image, bboxes = detect_enemy(yolo, np.copy(img), input_size=YOLO_INPUT_SIZE, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0)) | |
| if len(bboxes) > 0: | |
| CreateXMLfile("XML_Detections", str(int(time.time())), img, bboxes, read_class_names(TRAIN_CLASSES)) | |
| print("got it") |