Skip to content

Commit

Permalink
prevents replotting of existing plots during model evaluation (DeepLa…
Browse files Browse the repository at this point in the history
…bCut#2091)

* prevents replotting of existing plots during model evaluation
* fixed concatenation of evaluation results to keep chronological order
  • Loading branch information
ludovicbellier authored Dec 21, 2022
1 parent 6870a47 commit 8945e24
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions deeplabcut/pose_estimation_tensorflow/core/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ def return_evaluate_network_data(
# Data=pd.read_hdf(os.path.join(cfg["project_path"],str(trainingsetfolder),'CollectedData_' + cfg["scorer"] + '.h5'),'df_with_missing')

# Get list of body parts to evaluate network for
comparisonbodyparts = auxiliaryfunctions.intersection_of_body_parts_and_ones_given_by_user(
cfg, comparisonbodyparts
comparisonbodyparts = (
auxiliaryfunctions.intersection_of_body_parts_and_ones_given_by_user(
cfg, comparisonbodyparts
)
)
##################################################
# Load data...
Expand Down Expand Up @@ -660,8 +662,10 @@ def evaluate_network(
)

# Get list of body parts to evaluate network for
comparisonbodyparts = auxiliaryfunctions.intersection_of_body_parts_and_ones_given_by_user(
cfg, comparisonbodyparts
comparisonbodyparts = (
auxiliaryfunctions.intersection_of_body_parts_and_ones_given_by_user(
cfg, comparisonbodyparts
)
)
# Make folder for evaluation
auxiliaryfunctions.attempttomakefolder(
Expand Down Expand Up @@ -954,25 +958,30 @@ def evaluate_network(
DataCombined = pd.concat(
[Data.T, DataMachine.T], axis=0, sort=False
).T
print(
"Plotting...(attention scale might be inconsistent in comparison to when data was analyzed; i.e. if you used rescale)"
)
foldername = os.path.join(
str(evaluationfolder),
"LabeledImages_"
+ DLCscorer
+ "_"
+ Snapshots[snapindex],
)
auxiliaryfunctions.attempttomakefolder(foldername)
Plotting(
cfg,
comparisonbodyparts,
DLCscorer,
trainIndices,
DataCombined * 1.0 / scale,
foldername,
)
if not os.path.exists(foldername):
print(
"Plotting...(attention scale might be inconsistent in comparison to when data was analyzed; i.e. if you used rescale)"
)
auxiliaryfunctions.attempttomakefolder(foldername)
Plotting(
cfg,
comparisonbodyparts,
DLCscorer,
trainIndices,
DataCombined * 1.0 / scale,
foldername,
)
else:
print(
"Plots already exist for this snapshot... Skipping to the next one."
)

if len(final_result) > 0: # Only append if results were calculated
make_results_file(final_result, evaluationfolder, DLCscorer)
Expand Down Expand Up @@ -1010,7 +1019,7 @@ def make_results_file(final_result, evaluationfolder, DLCscorer):
output_path = os.path.join(str(evaluationfolder), DLCscorer + "-results.csv")
if os.path.exists(output_path):
temp = pd.read_csv(output_path, index_col=0)
df = pd.concat((df, temp)).reset_index(drop=True)
df = pd.concat((temp, df)).reset_index(drop=True)

df.to_csv(output_path)

Expand All @@ -1022,7 +1031,7 @@ def make_results_file(final_result, evaluationfolder, DLCscorer):
)
if os.path.exists(output_path):
temp = pd.read_csv(output_path, index_col=0)
df = pd.concat((df, temp)).reset_index(drop=True)
df = pd.concat((temp, df)).reset_index(drop=True)

df.to_csv(output_path)

Expand Down

0 comments on commit 8945e24

Please sign in to comment.