def visualizeOutputs(self): """Gui for adding overlay with live visualization of predictions.""" filters = ["Model (*.json)"] # Default to opening from models directory from project models_dir = None if self.state["filename"] is not None: models_dir = os.path.join(os.path.dirname(self.state["filename"]), "models/") # Show dialog filename, selected_filter = FileDialog.open( self, dir=models_dir, caption="Import model outputs...", filter=";;".join(filters), ) if len(filename) == 0: return # Model as overlay datasource # This will show live inference results from sleap.gui.overlays.base import DataOverlay overlay = DataOverlay.from_model(filename, self.state["video"], player=self.player) self.overlays["inference"] = overlay self.plotFrame()
def select_file(*args, x=field): filter = item.get("filter", "Any File (*.*)") filename, _ = FileDialog.open( None, directory=None, caption="Open File", filter=filter ) if len(filename): x.setText(filename) self.valueChanged.emit()
def doFileSelection(self): """Shows file browser to add training profile for given model type.""" filename, _ = FileDialog.open( None, dir=None, caption="Select training configuration file...", filter="JSON (*.json)", ) return self._cfg_getter.try_loading_path(filename) if filename else None
def visualizeOutputs(self): """Gui for adding overlay with live visualization of predictions.""" filters = ["Model (*.json)"] # Default to opening from models directory from project models_dir = None if self.state["filename"] is not None: models_dir = os.path.join(os.path.dirname(self.state["filename"]), "models/") # Show dialog filename, selected_filter = FileDialog.open( self, dir=models_dir, caption="Import model outputs...", filter=";;".join(filters), ) if len(filename) == 0: return # Model as overlay datasource # This will show live inference results from sleap.gui.overlays.base import DataOverlay predictor = DataOverlay.make_predictor(filename) show_pafs = False # If multi-head model with both confmaps and pafs, # ask user which to show. if (predictor.confidence_maps_key_name and predictor.part_affinity_fields_key_name): results = FormBuilderModalDialog( form_name="head_type_form").get_results() show_pafs = "Part Affinity" in results["head_type"] overlay = DataOverlay.from_predictor( predictor=predictor, video=self.state["video"], player=self.player, show_pafs=show_pafs, ) self.overlays["inference"] = overlay self.plotFrame()
def locateFile(self, idx: int): """Shows dialog for user to locate a specific missing file.""" old_filename = self.filenames[idx] _, old_ext = os.path.splitext(old_filename) caption = f"Please locate {old_filename}..." filters = [f"Missing file type (*{old_ext})", "Any File (*.*)"] new_filename, _ = FileDialog.open(None, dir=None, caption=caption, filter=";;".join(filters)) if new_filename: # Try using this change to find other missing files self.setFilename(idx, new_filename) # Redraw the table self.file_table.reset()