def run_concurrent(self, args, sign_progress): mode = args['mode'] movie_path = args['movie_path'] scr_paths = args['scr_paths'] segment_ids = args['segment_ids'] segment_ranges = args['segment_ranges'] timestamps = args['timestamps'] if mode == 0: return self.mode_time(movie_path, timestamps, scr_paths, sign_progress) elif mode == 1: result = [] for u in np.unique(np.array(segment_ids)).tolist(): indices = np.where(np.array(segment_ids) == u)[0] p_paths = [] for i, p in enumerate(scr_paths): if i in indices: p_paths.append(p) try: result.extend(self.mode_complete(movie_path, p_paths, sign_progress, segment_ranges[u][0], segment_ranges[u][1])) except IndexError as e: log_warning("There is no Segment with Index:" + u + " in the Segmentation, skipped images:" + str(p_paths)) return result else: return self.mode_complete(movie_path, scr_paths, sign_progress)
def run_selection(self): if self.project is not None: if self.main_window.vian_event_handler.current_pipeline is None: return container = self.project.selected scrs = [s for s in container if isinstance(s, Screenshot)] segments = [s for s in container if isinstance(s, Segment)] annotations = [s for s in container if isinstance(s, Annotation)] missing_info = self.project.get_missing_analyses( self.main_window.vian_event_handler.current_pipeline. requirements, screenshots=scrs, annotations=annotations, segments=segments) missing = dict() log_info("## Missing Analyses in Pipeline ##") for k in missing_info.keys(): # print(k, missing_info[k], missing.items()) missing[k] = missing_info[k][0] log_info("## -- ", k, missing_info[k][2], missing_info[k][1], missing_info[k][0]) experiment = self.main_window.vian_event_handler.current_pipeline.experiment if experiment is None: log_error("Experiment not found for RunAll") return for cl in missing.keys(): for priority in sorted(missing[cl].keys()): for analysis_name in missing[cl][priority].keys(): analysis = self.main_window.eval_class(analysis_name) for clobj_name, containers in missing[cl][priority][ analysis_name].items(): clobj = experiment.get_classification_object_by_name( clobj_name) if clobj is None: log_warning("Classification Object not found") continue d = dict(analysis=analysis(), targets=containers, parameters=None, classification_objs=clobj) log_info("Pipeline Analysis: ", priority, analysis_name, clobj_name) self.onRunAnalysis.emit(d)
def save(self, path=None): """ Serializes a Corpus into a json file """ if path is None and self.file is None: log_warning( "No path set for this corpus. First time, the path has to be given. The defaul name is used" ) self.file = os.path.join(self.directory, self.name) path = self.file elif self.file is not None: path = self.file if self.CORPUS_FILE_EXTENSION not in path: path += self.CORPUS_FILE_EXTENSION with open(path, "w") as f: json.dump(self.serialize(), f)
def apply_vocabulary(self, table, project: VIANProject, print_failed = False): if table is None: return voc_names = [v.name for v in project.vocabularies] voc_obj = [v for v in project.vocabularies] segments = [] skipped = 0 added = 0 for i, row in enumerate(table): category = row[0] if category in voc_names: voc = voc_obj[voc_names.index(category)] for j in range(1, len(row)): segm = [j - 1, []] word_group = row[j] for word in word_group: if word != "": word_obj = voc.get_word_by_name(word) if word_obj is None: skipped += 1 else: added += 1 segm[1].append(word_obj) segments.append(segm) else: log_warning("No Such Category:", category.replace(" ", "_")) main_seg = project.get_main_segmentation() log_info("Main Segmentation Length: ",len(main_seg.segments)) for s in segments: idx = s[0] objs = s[1] if idx < len(main_seg.segments): pass #TODO Reimplement # for word in objs: # main_seg.segments[idx].add_word(word) else: log_warning("Sub-Segmentation Ignored") log_info("Filemaker Data Loaded") log_info("Skipped: ", skipped) log_info(" Added: ", added)
def get_type(self): log_warning("ISelectable: Not Implemented by", self)
def set_name(self, name): log_warning("IHasName: Not Implemented by", self)
def get_timeline_visibility(self): log_warning("ITimelineItem: Not Implemented", self)
def move(self, start, end): log_warning("ITimelineItem: Not Implemented", self)
def set_end(self, end): log_warning("ITimelineItem: Not Implemented", self)
def set_start(self, start): log_warning("ITimelineItem: Not Implemented", self)
def get_start(self): log_warning("ITimelineItem: Not implemented", self)