Skip to content

Commit

Permalink
fix model storage issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ajithvcoder committed Nov 25, 2024
1 parent 95cce0f commit bda5be5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/data
.aim
model_storage*
model_storage/*
*__pycache__*
logs/*
credentials.json
Expand Down
12 changes: 7 additions & 5 deletions dvc.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schema: '2.0'
stages:
train:
cmd: python src/train.py --multirun --config-name=train experiment=catdog_ex trainer.max_epochs=2
cmd: python src/train.py --multirun --config-name=train experiment=catdog_ex trainer.max_epochs=3
deps:
- path: configs/experiment/catdog_ex.yaml
hash: md5
Expand All @@ -23,8 +23,8 @@ stages:
deps:
- path: configs/experiment/catdog_ex.yaml
hash: md5
md5: 959c64c29a91c7f7b4448e0c5cbc54f1
size: 1215
md5: d82b5d6fb9758f53546f97bda014f6f2
size: 1243
- path: src/eval.py
hash: md5
md5: 47a9e50a0213ee71ff67a97b71d1ca6e
Expand All @@ -34,9 +34,11 @@ stages:
deps:
- path: configs/experiment/catdog_ex.yaml
hash: md5
md5: 959c64c29a91c7f7b4448e0c5cbc54f1
size: 1215
md5: d82b5d6fb9758f53546f97bda014f6f2
size: 1243
- path: src/infer.py
hash: md5
md5: 1b360e17f7740c9bd6eba9c52e0dc5d2
size: 4717
code-test-coverage:
cmd: pytest --cov-report term --cov=src/ tests/
1 change: 1 addition & 0 deletions gradio_demo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, model_path="model_storage/epoch-checkpoint_patch_size-8_embed
self.model = self.model.to(self.device)
self.model.eval()
# test comment
# test comment 2

# Define the same transforms used during training/testing
self.transform = transforms.Compose([
Expand Down
3 changes: 2 additions & 1 deletion scripts/multirun_metrics_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def get_metrics(log_dir, timestamp, mode):
for run in os.listdir(metrics_dir):
metrics_file = os.path.join(metrics_dir, run, "csv", "version_0", 'metrics.csv')
if os.path.exists(metrics_file):
print(metrics_file)
metrics_csv_dict[int(run)] = read_csv_to_dict(metrics_file)
return metrics_csv_dict

Expand Down Expand Up @@ -75,7 +76,7 @@ def main_run():
assert list(train_metrics.keys()).sort() == list(hyperparams.keys()).sort()

data = [["Exp No"]]
# print(train_metrics)
print(train_metrics)
metrics_keys = train_metrics[0].keys()
hyperparams_keys = hyperparams[0].keys()
data[0].extend(metrics_keys)
Expand Down
2 changes: 1 addition & 1 deletion src/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _save_checkpoint(self, trainer, filepath):
# Export the model to TorchScript
example_input = torch.randn(1, 3, 224, 224) # Example input for tracing
try:
# model_torch = copy.deepcopy(trainer.model)
model_torch = copy.deepcopy(trainer.model)
torchscript_model = model_torch.to_torchscript(method="trace", example_inputs=example_input)

# Save the TorchScript model
Expand Down

0 comments on commit bda5be5

Please sign in to comment.