Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions LabGym/gui_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ def __init__(self,parent,title,name_and_color):



class WindowLv2_AnalyzeBehaviors(wx.Frame):
class PanelLv2_AnalyzeBehaviors(wx.Panel):

'''
The 'Analyze Behaviors' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_AnalyzeBehaviors,self).__init__(parent=None,title=title,size=(1000,530))
super().__init__(parent)
self.notebook = parent
self.behavior_mode=0 # 0--non-interactive, 1--interactive basic, 2--interactive advanced, 3--static images
self.use_detector=False # whether the Detector is used
self.detector_path=None # the 'LabGym/detectors' folder, which stores all the trained Detectors
Expand Down Expand Up @@ -136,7 +137,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_selectcategorizer=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -1096,15 +1097,16 @@ def analyze_behaviors(self,event):



class WindowLv2_MineResults(wx.Frame):
class PanelLv2_MineResults(wx.Panel):

'''
The 'Mine Results' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_MineResults,self).__init__(parent=None,title=title,size=(1000,260))
super().__init__(parent)
self.notebook = parent
self.file_path=None # the path to LabGym analysis results
self.result_path=None # the folder to store data mining results
self.dataset=None # store the dataset in RAM
Expand All @@ -1119,7 +1121,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputfolder=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -1274,15 +1276,16 @@ def mine_data(self,event):



class WindowLv2_PlotBehaviors(wx.Frame):
class PanelLv2_PlotBehaviors(wx.Panel):

'''
The 'Plot Behaviors' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_PlotBehaviors,self).__init__(parent=None,title=title,size=(1000,260))
super().__init__(parent)
self.notebook = parent
self.events_probability=None # read from 'all_events.xsls' to store the behavior events and probability of each animal / object
self.time_points=None # the frame-wise time points of the events_probablity
self.results_folder=None # the folder that stores the ouput behavior plot
Expand All @@ -1293,7 +1296,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputfile=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -1386,15 +1389,16 @@ def plot_behavior(self,event):



class WindowLv2_CalculateDistances(wx.Frame):
class PanelLv2_CalculateDistances(wx.Panel):

'''
The 'Calculate Distances' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_CalculateDistances,self).__init__(parent=None,title=title,size=(1000,260))
super().__init__(parent)
self.notebook = parent
self.path_to_analysis_results=None # the folder that stores LabGym analysis results
self.out_path=None # the folder to store the calculated distances
self.behavior_to_include=None # the behaviors used in calculation
Expand All @@ -1404,7 +1408,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputfolder=wx.BoxSizer(wx.HORIZONTAL)
Expand Down
62 changes: 36 additions & 26 deletions LabGym/gui_categorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@
the_absolute_current_path=str(Path(__file__).resolve().parent)


class WindowLv2_GenerateExamples(wx.Frame):
class PanelLv2_GenerateExamples(wx.Panel):

'''
The 'Generate Behavior Examples' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_GenerateExamples,self).__init__(parent=None,title=title,size=(1000,530))
super().__init__(parent)
self.notebook = parent
self.behavior_mode=0 # 0: non-interactive behavior; 1: interact basic; 2: interact advanced; 3: static images
self.use_detector=False # whether the Detector is used
self.detector_path=None # the 'LabGym/detectors' folder, which stores all the trained Detectors
Expand Down Expand Up @@ -93,7 +94,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_specifymode=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -672,21 +673,22 @@ def generate_data(self,event):



class WindowLv2_SortBehaviors(wx.Frame):
class PanelLv2_SortBehaviors(wx.Panel):

'''
The 'Sort Behavior Examples' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_SortBehaviors,self).__init__(parent=None,title=title,size=(500,230))
super().__init__(parent)
self.notebook = parent
self.display_window()


def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)
boxsizer.Add(0,40,0)

Expand All @@ -710,24 +712,29 @@ def display_window(self):

def sort_examples(self,event):

WindowLv3_SortExamples('Sort Examples (LabGym UI)')
panel = PanelLv3_SortExamples(self.notebook)
title = 'Sort Examples (LabGym UI)'
self.notebook.AddPage(panel, title, select=True)


def sort_examples_csv(self,event):

WindowLv3_SortExamplesCSV('Sort Examples (from .csv)')
panel = PanelLv3_SortExamplesCSV(self.notebook)
title = 'Sort Examples (from .csv)'
self.notebook.AddPage(panel, title, select=True)



class WindowLv3_SortExamples(wx.Frame):
class PanelLv3_SortExamples(wx.Panel):

'''
The 'Sort Examples (LabGym UI)' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv3_SortExamples,self).__init__(parent=None,title=title,size=(1000,260))
super().__init__(parent)
self.notebook = parent
self.input_path=None # the folder that stores unsorted behavior examples (one example is a pair of an animation and a pattern image)
self.result_path=None # the folder that stores the sorted behavior examples
self.keys_behaviors={} # stores the pairs of shortcut key-behavior name
Expand All @@ -738,7 +745,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputfolder=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -965,15 +972,16 @@ def sort_behaviors(self,event):



class WindowLv3_SortExamplesCSV(wx.Frame):
class PanelLv3_SortExamplesCSV(wx.Panel):

'''
The 'Sort Examples (from .csv)' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv3_SortExamplesCSV,self).__init__(parent=None,title=title,size=(1000,220))
super().__init__(parent)
self.notebook = parent
self.path_to_examples=None # path to unsorted behavior examples generated by LabGym, should also contain the annotation '.csv' file
self.result_path=None # the folder for storing sorted behavior examples

Expand All @@ -982,7 +990,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputexamples=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -1046,15 +1054,16 @@ def sort_fromcsv(self,event):



class WindowLv2_TrainCategorizers(wx.Frame):
class PanelLv2_TrainCategorizers(wx.Panel):

'''
The 'Train Categorizers' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_TrainCategorizers,self).__init__(parent=None,title=title,size=(1000,540))
super().__init__(parent)
self.notebook = parent
self.file_path=None # the folder that stores sorted, unprepared behavior examples (each category is a subfolder)
self.new_path=None # the folder that stores prepared behavior examples (contains all examples with a category tag in their names)
self.behavior_mode=0 # 0--non-interactive, 1--interactive basic, 2--interactive advanced, 3--static images
Expand Down Expand Up @@ -1085,7 +1094,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputexamples=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -1558,15 +1567,16 @@ def train_categorizer(self,event):



class WindowLv2_TestCategorizers(wx.Frame):
class PanelLv2_TestCategorizers(wx.Panel):

'''
The 'Test Categorizers' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_TestCategorizers,self).__init__(parent=None,title=title,size=(1000,260))
super().__init__(parent)
self.notebook = parent
self.file_path=None # the folder that stores the ground-truth examples (each subfolder is a behavior category)
self.model_path=os.path.join(the_absolute_current_path,'models') # the 'LabGym/models' folder, which stores all the trained Categorizers
self.path_to_categorizer=None # path to the Categorizer
Expand All @@ -1577,7 +1587,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_selectcategorizer=wx.BoxSizer(wx.HORIZONTAL)
Expand Down
27 changes: 15 additions & 12 deletions LabGym/gui_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@
the_absolute_current_path=str(Path(__file__).resolve().parent)


class WindowLv2_GenerateImages(wx.Frame):
class PanelLv2_GenerateImages(wx.Panel):

'''
The 'Generate Images' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_GenerateImages,self).__init__(parent=None,title=title,size=(1000,350))
super().__init__(parent)
self.notebook = parent
self.path_to_videos=None # path to a batch of videos for generate images (extract frames)
self.result_path=None # the folder for storing the generate images (extract frames)
self.framewidth=None # if not None, will resize the video frame keeping the original w:h ratio
Expand All @@ -61,7 +62,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_inputvideos=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -225,15 +226,16 @@ def generate_images(self,event):



class WindowLv2_TrainDetectors(wx.Frame):
class PanelLv2_TrainDetectors(wx.Panel):

'''
The 'Train Detectors' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_TrainDetectors,self).__init__(parent=None,title=title,size=(1000,300))
super().__init__(parent)
self.notebook = parent
self.path_to_trainingimages=None # the folder that stores all the training images
self.path_to_annotation=None # the path to the .json file that stores the annotations in coco format
self.inference_size=480 # the Detector inferencing frame size
Expand All @@ -246,7 +248,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_selectimages=wx.BoxSizer(wx.HORIZONTAL)
Expand Down Expand Up @@ -378,15 +380,16 @@ def train_detector(self,event):



class WindowLv2_TestDetectors(wx.Frame):
class PanelLv2_TestDetectors(wx.Panel):

'''
The 'Test Detectors' functional unit
'''

def __init__(self,title):
def __init__(self, parent):

super(WindowLv2_TestDetectors,self).__init__(parent=None,title=title,size=(1000,300))
super().__init__(parent)
self.notebook = parent
self.path_to_testingimages=None # the folder that stores all the testing images
self.path_to_annotation=None # the path to the .json file that stores the annotations in coco format
self.detector_path=os.path.join(the_absolute_current_path,'detectors') # the 'LabGym/detectors' folder, which stores all the trained Detectors
Expand All @@ -398,7 +401,7 @@ def __init__(self,title):

def display_window(self):

panel=wx.Panel(self)
panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)

module_selectdetector=wx.BoxSizer(wx.HORIZONTAL)
Expand Down
Loading
Loading