示例#1
0
def generate_new_round(dframeList, currentBand, this_round, handicap = False):
    dframe = dframeList[currentBand]
    sortedFrame = MMS.sort_by_mms(dframeList, currentBand, False, handicap)
    oppset = {}
    for i,item in sortedFrame['history'].iteritems():
        os=set()
        if (item!=""):
            for opp in item.split(";"):
                if (opp.lower() != 'bye'):
                    os.add(int(opp[1:-1]))
        oppset[sortedFrame['id'][i]]=os

    finalPairing = {}
    currentIndex = []
    currentSet = set()
    finalList = []
    if (this_round == 0): #special treatment for the very first round for performance consideration
        first_pairing = get_foldpairing(len(sortedFrame))
        finalList.append((0, first_pairing))
    else:
        totalCount = [0]
        get_mutation(sortedFrame, 0, finalPairing, currentIndex, currentSet, oppset, totalCount)
        topPairings = sorted(finalPairing.iteritems())[0]
        random.shuffle(topPairings[1])
        for item in topPairings[1]:
            finalList.append((topPairings[0], item))

    return finalList, sortedFrame
示例#2
0
def azureml_main(dataframe1 = None, results = None):

    # Execution logic goes here
    if (dataframe1 is None):
        return pandas.DataFrame(columns=['id','name','rank','history'])
    rawframe = dataframe1.fillna("")
    df, handicap = read_round(rawframe)
    for i in range(0, len(df)-1):
        df[i] = update_round(df[i], results)
        df[i] = MMS.sort_by_mms(df, i, dropAux=False, handicap=handicap[i])
        #allStanding.append(dfRound[i].copy())

    #newframe = update_round(rawframe, results)
    #newframe = pandas.concat(df, ignore_index=True)
    newframe = df[0]
    for i in range(1, len(df)-1):
        if handicap[i]:
            newframe.loc[len(newframe)] = ['&','&','&','&','&','&','&']
        else:
            newframe.loc[len(newframe)] = ['=','=','=','=','=','=','=']
        newframe = newframe.append(df[i])

    # If a zip file is connected to the third input port is connected,
    # it is unzipped under ".\Script Bundle". This directory is added
    # to sys.path. Therefore, if your zip file contains a Python file
    # mymodule.py you can import it using:
    # import mymodule

    # Return value must be of a sequence of pandas.DataFrame
    return newframe
 def addNewContainer(self, containername):
     if containername == Names.Containers["SMS"]:
         self.myContainers[containername] = SMS.SMS(containername, self)
     elif containername == Names.Containers["RPDU"]:
         self.myContainers[containername] = RPDU.RPDU(containername, self)
     elif containername == Names.Containers["UD"]:
         self.myContainers[containername] = UD.UD(containername, self)
     elif containername == Names.Containers["WSP"]:
         self.myContainers[containername] = WSP.WSP(containername, self)
     elif containername == Names.Containers["WBXML"]:
         self.myContainers[containername] = WBXML.WBXML(containername, self)
     elif containername == Names.Containers["SIMCMD"]:
         self.myContainers[containername] = SIMCmd.SIMCmd(
             containername, self)
     elif containername == Names.Containers["MMS"]:
         self.myContainers[containername] = MMS.MMS(containername, self)
     elif containername == Names.Containers["ENVELOPE"]:
         self.myContainers[containername] = Envelope.Envelope(
             containername, self)
示例#4
0
def FaceDetection(image):
    try:
        FaceFound = 'false'
        #Detection Models
        Prototxt = "ModelFaceRec.prototxt.txt"  #ConfigValues.ReturnRDODProtoTXT()
        Model = "ModelFaceRec.caffemodel"  #ConfigValues.ReturnRTODModel()
        SystemConfidence = ConfigValues.ReturnRTODSystemConfidence()

        net = cv2.dnn.readNetFromCaffe(Prototxt, Model)
        # load the input image and construct an input blob for the image
        # by resizing to a fixed 300x300 pixels and then normalizing it
        (h, w) = image.shape[:2]
        blob = cv2.dnn.blobFromImage(cv2.resize(image, (300, 300)), 1.0,
                                     (300, 300), (104.0, 177.0, 123.0))
        # pass the blob through the network and obtain the detections and
        # predictions
        print("[INFO] computing object detections...")
        net.setInput(blob)
        detections = net.forward()

        # loop over the detections
        DetectedFaces = []
        for i in range(0, detections.shape[2]):
            # extract the confidence (i.e., probability) associated with the
            # prediction
            confidence = detections[0, 0, i, 2]
            # filter out weak detections by ensuring the `confidence` is
            # greater than the minimum confidence
            if confidence > SystemConfidence:
                # compute the (x, y)-coordinates of the bounding box for the
                # object
                box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
                (startX, startY, endX, endY) = box.astype("int")

                #Grab ROI
                #[startY:endY, startX:endX]
                roi = image[startY:endY, startX:endX]
                DetectedFaces.append(roi)

        for df in DetectedFaces:
            FaceFound = 'true'
            #upload to DropBox
            #Path to Temp Save Alert Images
            Image_Path = "FaceDetection.jpeg"
            #Save Image to Disk
            cv2.imwrite(Image_Path, df)
            URL = DropBox.UploadToDropBox(Image_Path)
            print("DropBox Image Public Share URL: " + str(URL))

            #Send MMS
            if (ConfigValues.ReturnTwilioMMSEnabled() == 'true'):
                PhoneDestination = ConfigValues.ReturnAlertPhoneDestination()
                for PD in PhoneDestination:
                    MMS.Send_MMS(
                        "FaceDetection " +
                        str(datetime.datetime.today().strftime(
                            '%d-%m-%Y-%H-%M-%S')), PD, URL)
                print("MMS Alerts Sent")

        return FaceFound
    except:
        print("Oops!, Face Detection Error: ", sys.exc_info()[0], "occurred.")