Skip to content

Comments

Fix: Replace Hardcoded Absolute Paths with argparse in BYOL/Inference Scripts#144

Open
Apprentice2907 wants to merge 4 commits intoML4SCI:mainfrom
Apprentice2907:Hardcoded-Absolute-Paths-BYOL/Inference
Open

Fix: Replace Hardcoded Absolute Paths with argparse in BYOL/Inference Scripts#144
Apprentice2907 wants to merge 4 commits intoML4SCI:mainfrom
Apprentice2907:Hardcoded-Absolute-Paths-BYOL/Inference

Conversation

@Apprentice2907
Copy link

Fixes #143

Problem

Several Python scripts in the Transformers_Classification_DeepLense_Kartik_Sachdev
sub-project contained hardcoded absolute paths pointing to the original developer's
local machine. This made fine-tuning and inference completely non-functional for any
other contributor without manually editing source files.

Changes Made

The following files were updated to replace hardcoded paths with argparse CLI arguments:

  • finetune.py — replaced hardcoded saved_model_path and device
  • finetune_byol.py — replaced hardcoded saved_model_path, finetuned_model_path and device
  • inference.py — replaced hardcoded log_dir, finetune_model_path and device
  • self_supervised/examples/byol/finetune_byol.py — replaced hardcoded pretrained_model_path, finetuned_model_path and device
  • self_supervised/examples/byol/inference_byol.py — replaced hardcoded log_dir, finetune_model_path and device
  • self_supervised/examples/byol/load_pretrained_byol.py — replaced hardcoded pretrained_model_path, finetuned_model_path and device

How to Run After Fix

Scripts now accept paths as command-line arguments, for example:
python inference.py --log_dir ./logger/2023-07-23 --finetune_model_path ./checkpoint/model.pt

Testing

Verified no hardcoded paths remain using:
grep -rn "/home|/content/drive|/root|/Users" --include="*.py" .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{Bug] Hardcoded Absolute Paths in BYOL/Inference Scripts (Transformers Classification DeepLense)

1 participant