Skip to content

Commit

Permalink
Fix notebook model loading for updated qat
Browse files Browse the repository at this point in the history
  • Loading branch information
seldauyanik-maxim committed Dec 17, 2024
1 parent 802d98e commit 51030d1
Show file tree
Hide file tree
Showing 9 changed files with 8,466 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.9
3.11.8
90 changes: 47 additions & 43 deletions notebooks/AutoEncoder_Evaluation.ipynb

Large diffs are not rendered by default.

8,339 changes: 8,312 additions & 27 deletions notebooks/Bayer2RGB_Evaluation.ipynb

Large diffs are not rendered by default.

32 changes: 6 additions & 26 deletions notebooks/DatasetVisualization_pascalvoc.ipynb

Large diffs are not rendered by default.

99 changes: 49 additions & 50 deletions notebooks/FPNDetectorModelVisualization_pascalvoc_quantized.ipynb

Large diffs are not rendered by default.

49 changes: 28 additions & 21 deletions notebooks/TinySSDModelVisualization_svhn.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pyffmpeg==2.4.2.18.1
pytorch-metric-learning==2.6.0
pytube==15.0.0
qrcode==7.4.2
seaborn==0.13.2
scipy==1.14.0
soundfile==0.12.1
tensorboard==2.17.0
Expand Down
7 changes: 5 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,11 @@ def update_old_model_params(model_path, model_new):
old_model_path = os.path.join(dir_path, new_file_name)
os.rename(model_path, old_model_path)
torch.save(model_old, model_path)
msglogger.info('Model `%s` is old. Missing parameters added with default values!',
model_path)
if msglogger:
msglogger.info('Model `%s` is old. Missing parameters added with default values!',
model_path)
else:
print(f'Model {model_path} is old. Missing parameters added with default values!')


if __name__ == '__main__':
Expand Down
30 changes: 17 additions & 13 deletions utils/autoencoder_eval_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from torch import nn

import matplotlib.pyplot as plt
import seaborn as sns

sns.set_style("white")


DECAY_FACTOR = 1

Expand Down Expand Up @@ -186,19 +190,19 @@ def calc_ae_perf_metrics(reconstructions, inputs, labels, threshold, print_all=T
"""

loss_fn = nn.MSELoss(reduce=False)
FP = 0
FN = 0
TP = 0
TN = 0

Recall = -1
Precision = -1
Accuracy = -1
F1 = -1
FPRate = -1

BalancedAccuracy = -1
TNRate = -1 # specificity (SPC), selectivity
FP = torch.tensor(0).to(inputs[0].device)
FN = torch.tensor(0).to(inputs[0].device)
TP = torch.tensor(0).to(inputs[0].device)
TN = torch.tensor(0).to(inputs[0].device)

Recall = torch.tensor(-1).to(inputs[0].device)
Precision = torch.tensor(-1).to(inputs[0].device)
Accuracy = torch.tensor(-1).to(inputs[0].device)
F1 = torch.tensor(-1).to(inputs[0].device)
FPRate = torch.tensor(-1).to(inputs[0].device)

BalancedAccuracy = torch.tensor(-1).to(inputs[0].device)
TNRate = torch.tensor(-1).to(inputs[0].device) # specificity (SPC), selectivity

for i, inputs_batch in enumerate(inputs):
label_batch = labels[i]
Expand Down

0 comments on commit 51030d1

Please sign in to comment.