I have a python application in which I am feeding a Dictionary into a for loop and after the loop, I am inserting that Dictionary into a Tuple. After the Dictionary is inserted into Tuple, I give a .clear () to the Dictionary, for another loop of the loop, but when using .clear () Tuple is left with an empty collection. I already tried to add the data from the Dictionary in an auxiliary variable, to avoid this behavior, but that until then did not solve my problem. Does anyone know how I can remove the data from the Dictionary without affecting what was stored in the Tuple?
def predictPeople(imageByte, listEpis): image = UPLOAD_FOLDER+"/"+imageByte dateTime = datetime.now() stringDate = dateTime.strftime("%d/%m/%Y, %H:%M:%S") stringDate = stringDate.replace("/", "").replace(":", "").replace(", ", "") detector = ObjectDetection() detector.setModelTypeAsYOLOv3() detector.setModelPath(modelPeople) detector.loadModel() detectionList = [] detectionAllList = () resultFolder = pathImageResult + "/" + stringDate + ".jpg" custom = detector.CustomObjects(person=True) folders = None detections = detector.detectCustomObjectsFromImage(custom_objects=custom, input_image=image, output_image_path=resultFolder, extract_detected_objects=True, minimum_percentage_probability=50) if len(detections) > 0: folder = resultFolder+"-objects" obj = RecognitioCustonImage(folder) #Bring up a list of folders with images folders = obj.detectEpi() peopleDetection = {} imageDetectionPeople = {} #Scrolls through a list of folders for fold in folders: #Lists images in a folder detectionImages = os.listdir(os.path.join(fold)) #Scroll through the list of images in a folder for peopleImage in detectionImages: imagePath = fold+"/"+peopleImage imageDetectionPeople.update({str(peopleImage):Convert(imagePath)}) auxImage = imageDetectionPeople peopleDetection.update({"Pessoa":auxImage}) y = list(detectionAllList) auxPeople = peopleDetection y.append(auxPeople) #Stores the list of images in another list detectionAllList = tuple(y) peopleDetection.clear() imageDetectionPeople.clear() return jsonify(detectionAllList) https://stackoverflow.com/questions/65572692/tuple-data-is-removed-with-clear-from-a-dictionary January 05, 2021 at 11:06AM
没有评论:
发表评论