def __init__(self, fontScale=1.0): print("YoloInference::__init__()") print( "===============================================================") print("Initialising Yolo Inference with the following parameters: ") print("") self.classLabels = None self.colors = None self.nmsThreshold = 0.35 self.fontScale = float(fontScale) self.fontThickness = 2 self.net = None self.rgb = True self.verbose = False self.lastMessageSentTime = datetime.now() # Read class names from text file print(" - Setting Classes") with open(classesFile, 'r') as f: self.classLabels = [line.strip() for line in f.readlines()] # Generate colors for different classes print(" - Setting Colors") self.colors = np.random.uniform(0, 255, size=(len(self.classLabels), 3)) # Read pre-trained model and config file print(" - Loading Model and Config") darknet.performDetect(configPath=yolocfg, weightPath=yoloweight, metaPath=dataFile, initOnly=True)
def __init__( self, fontScale = 1.0, sendMessage = False): logging.info('>> ' + self.__class__.__name__ + "." + sys._getframe().f_code.co_name + '()') logging.info('===============================================================') logging.info('Initializing Yolo Inference with the following parameters:') self.sendMessage = sendMessage self.classLabels = None self.colors = None self.nmsThreshold = 0.35 self.fontScale = float(fontScale) self.fontThickness = 2 self.net = None self.rgb = True self.verbose = False self.lastMessageSentTime = datetime.now() # Read class names from text file logging.info(' - Setting Classes') with open(classesFile, 'r') as f: self.classLabels = [line.strip() for line in f.readlines()] # Generate colors for different classes logging.info(' - Setting Colors') self.colors = np.random.uniform(100, 255, size=(len(self.classLabels), 3)) # Read pre-trained model and config file logging.info(' - Loading Model and Config') darknet.performDetect( configPath = yolocfg, weightPath = yoloweight, metaPath= dataFile, initOnly= True )
def upload(): target = os.path.join(APP_ROOT, 'images/') if not os.path.isdir(target): os.mkdir(target) for file in request.files.getlist("file"): print(file) filename = file.filename destination = "/".join([target, filename]) file.save(destination) result = darknet.performDetect( imagePath='/home/dsbaule/PycharmProjects/Sketch2AIA/src/Web/images/' + filename, thresh=0.25, configPath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/NewDatasetYolov3.cfg", weightPath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/NewDatasetYolov3_18000.weights", metaPath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/obj.data", showImage=True, makeImageOnly=True, initOnly=False) destination = "/".join([target, filename[:-4] + 'Generated.jpg']) import matplotlib matplotlib.image.imsave(destination, result['image']) return render_template("complete.html")
from darknet import darknet from src.Component import Component from src import Alignment from src.AIA import AIAProject, GenerateAIA result = darknet.performDetect( imagePath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/TestImg/sample3.jpg", thresh=0.25, configPath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/NewDatasetYolov3.cfg", weightPath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/NewDatasetYolov3_18000.weights", metaPath= "/home/dsbaule/PycharmProjects/Sketch2AIA/Custom_Darknet_Files/obj.data", showImage=False, makeImageOnly=False, initOnly=False) # for component in result: # print(component[0] + ':') # print('\t' + str(component[2][0])) # print('\t' + str(component[2][1])) # print('\t' + str(component[2][2])) # print('\t' + str(component[2][3])) componentList = list() for component in result: print(component[0]) if component[0] == 'Screen':