Skip to content

Update VisionClassifierTrainer #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions hugsvision/nnet/VisionClassifierTrainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(
cores = 4,
batch_size = 8,
lr = 2e-5,
eval_metric = "accuracy",
eval_metric = "loss",
fp16 = False,
classification_report_digits = 4,
checkpoint_path = None,
Expand Down Expand Up @@ -62,14 +62,14 @@ def __init__(

# Processing device (CPU / GPU)
self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

# Get the classifier collator
self.collator = ImageClassificationCollator(self.feature_extractor)

# Get the model output path
self.output_path = self.__getOutputPath()
self.logs_path = self.output_path

# Open the logs file
self.__openLogs()

Expand All @@ -87,12 +87,12 @@ def __init__(
num_train_epochs = self.max_epochs,
metric_for_best_model = self.eval_metric,
logging_dir = self.logs_path,
evaluation_strategy = "epoch",
eval_strategy = "epoch",
load_best_model_at_end = False,
overwrite_output_dir = True,
fp16=self.fp16,
)

self.trainer = Trainer(
self.model,
self.training_args,
Expand Down Expand Up @@ -122,7 +122,7 @@ def __init__(
"""
📜 Open the logs file
"""
def __openLogs(self):
def __openLogs(self):

# Open the logs file
self.logs_file = open(self.logs_path + "/logs.txt", "a")
Expand Down Expand Up @@ -174,7 +174,7 @@ def evaluate_f1_score(self):
🧪 Evaluate the performances of the system of the test sub-dataset
"""
def evaluate(self):

all_preds = []
all_target = []

Expand Down