def modeContrastive(pathToLabel, pathToEvidence, submissionName): # get list of submission submissions = getSubmissions() if submissionName == 'primary': reportErrorAndExit( 'Please use a different name for your contrastive submission.') if not submissions.empty: nContrastive = len(submissions[submissions.type == 'contrastive']) if nContrastive > 3: reportErrorAndExit( 'Please delete one of your existing ' 'contrastive submissions first.') nSameName = len(submissions[submissions.name == submissionName]) if nSameName > 0: reportErrorAndExit( 'Please choose a different name or ' 'delete the existing submission with same name.') initializeForSubmission() # load evidence/label files and check their validity label = loadLabel(pathToLabel) evidence = loadEvidence(pathToEvidence) try: checkSubmission(label, evidence) except ValueError, e: reportErrorAndExit(e.message)
def modeCheck(pathToLabel, pathToEvidence): initializeForSubmission() label = loadLabel(pathToLabel) evidence = loadEvidence(pathToEvidence) try: checkSubmission(label, evidence) except ValueError, e: reportErrorAndExit(e.message)
def loadFiles(shot, reference, label): shot = loadShot(shot) label = loadLabel(label) checkSubmission(shot, label) reference = loadLabelReference(reference) return shot, reference, label
def loadFiles(shot, reference, evireference, label, evidence, consensus=None): shot = loadShot(shot) label = loadLabel(label) evidence = loadEvidence(evidence) # check that labels are only provided for selected shots labelShots = set( tuple(s) for _, s in label[['videoID', 'shotNumber']].iterrows()) if not labelShots.issubset(set(shot.index)): msg = ('Labels should only be computed for provided shots.') raise ValueError(msg) # check that evidence is provided for every unique label labelNames = set(label['personName'].unique()) evidenceNames = set(evidence['personName'].unique()) if labelNames != evidenceNames: msg = ('There must be exactly one evidence ' 'per unique name in label submission.') raise ValueError(msg) # check that there is no more than one evidence per label if len(evidenceNames) != len(evidence): msg = ('There must be exactly one evidence ' 'per unique name in label submission.') raise ValueError(msg) # check that evidences are chosen among selected shots evidenceShots = set(tuple(s) for _, s in evidence[['videoID', 'shotNumber']].iterrows()) if not evidenceShots.issubset(set(shot.index)): msg = ('Evidences should only be chosen among provided shots.') raise ValueError(msg) # only keep labels for shot with consensus if consensus: consensus = loadShot(consensus) mask = label.apply( lambda x: (x['videoID'], x['shotNumber']) in set(consensus.index), axis=1) label = label[mask] reference = loadLabelReference(reference) evireference = loadEvidenceReference(evireference) return reference, evireference, label, evidence
def loadFiles(shot, reference, label, consensus=None): shot = loadShot(shot) label = loadLabel(label) # check that labels are only provided for selected shots labelShots = set(tuple(s) for _, s in label[["videoID", "shotNumber"]].iterrows()) if not labelShots.issubset(set(shot.index)): msg = "Labels should only be computed for provided shots." raise ValueError(msg) # only keep labels for shot with consensus if consensus: consensus = loadShot(consensus) mask = label.apply(lambda x: (x["videoID"], x["shotNumber"]) in set(consensus.index), axis=1) label = label[mask] reference = loadLabelReference(reference) return reference, label
def modePrimary(pathToLabel, pathToEvidence): # get list of submission submissions = getSubmissions() if not submissions.empty: nPrimary = len(submissions[submissions.type == 'primary']) if nPrimary > 0: reportErrorAndExit( 'Please delete your existing ' 'primary submission first.') initializeForSubmission() # load evidence/label files and check their validity label = loadLabel(pathToLabel) evidence = loadEvidence(pathToEvidence) try: checkSubmission(label, evidence) except ValueError, e: reportErrorAndExit(e.message)
def loadFiles(shot, reference, label, consensus=None): shot = loadShot(shot) label = loadLabel(label) # check that labels are only provided for selected shots labelShots = set( tuple(s) for _, s in label[['videoID', 'shotNumber']].iterrows()) if not labelShots.issubset(set(shot.index)): msg = ('Labels should only be computed for provided shots.') raise ValueError(msg) # only keep labels for shot with consensus if consensus: consensus = loadShot(consensus) mask = label.apply( lambda x: (x['videoID'], x['shotNumber']) in set(consensus.index), axis=1) label = label[mask] reference = loadLabelReference(reference) return reference, label