From 5fadf7f72aa1115de66e61c980d24cdbb44aa3a0 Mon Sep 17 00:00:00 2001 From: codingwithsurya Date: Fri, 13 Oct 2023 02:55:45 +0000 Subject: [PATCH] :art: Format Python code with psf/black --- training/training/core/dataset.py | 12 ++++++------ training/training/core/dl_model.py | 2 +- training/training/routes/image/image.py | 6 ++---- training/training/urls.py | 1 + 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/training/training/core/dataset.py b/training/training/core/dataset.py index fa1bf6259..dd06a859b 100644 --- a/training/training/core/dataset.py +++ b/training/training/core/dataset.py @@ -130,7 +130,7 @@ def __init__( self.train_transform = train_transform or transforms.Compose( [transforms.ToTensor()] ) - + self.test_transform = test_transform or transforms.Compose( [transforms.ToTensor()] ) @@ -139,10 +139,10 @@ def __init__( # Ensure the directory exists os.makedirs(self.dataset_dir, exist_ok=True) - print(f'train transform: {train_transform}') - print(f'test transform: {test_transform}') + print(f"train transform: {train_transform}") + print(f"test transform: {test_transform}") # Load the datasets - + self.train_set = datasets.__dict__[dataset_name]( root=self.dataset_dir, train=True, @@ -182,7 +182,7 @@ def createTrainDataset(self) -> DataLoader: shuffle=self.shuffle, drop_last=True, ) - self.delete_datasets_from_directory() # Delete datasets after loading + self.delete_datasets_from_directory() # Delete datasets after loading return train_loader def createTestDataset(self) -> DataLoader: @@ -192,7 +192,7 @@ def createTestDataset(self) -> DataLoader: shuffle=self.shuffle, drop_last=True, ) - self.delete_datasets_from_directory() # Delete datasets after loading + self.delete_datasets_from_directory() # Delete datasets after loading return test_loader def getCategoryList(self) -> list[str]: diff --git a/training/training/core/dl_model.py b/training/training/core/dl_model.py index eb9625326..73cfc2095 100644 --- a/training/training/core/dl_model.py +++ b/training/training/core/dl_model.py @@ -17,7 +17,7 @@ class DLModel(nn.Module): "SIGMOID": nn.Sigmoid, "LOGSOFTMAX": nn.LogSoftmax, "CONV2D": nn.Conv2d, - "DROPOUT": nn.Dropout + "DROPOUT": nn.Dropout, } def __init__(self, layer_list: list[nn.Module]): diff --git a/training/training/routes/image/image.py b/training/training/routes/image/image.py index 0e74a01d5..8db19c803 100644 --- a/training/training/routes/image/image.py +++ b/training/training/routes/image/image.py @@ -16,9 +16,7 @@ @router.post("", auth=FirebaseAuth()) def imageTrain(request: HttpRequest, imageParams: ImageParams): if imageParams.default: - dataCreator = ImageDefaultDatasetCreator.fromDefault( - imageParams.default - ) + dataCreator = ImageDefaultDatasetCreator.fromDefault(imageParams.default) print(vars(dataCreator)) train_loader = dataCreator.createTrainDataset() test_loader = dataCreator.createTestDataset() @@ -37,7 +35,7 @@ def imageTrain(request: HttpRequest, imageParams: ImageParams): # ) model = DLModel.fromLayerParamsList(imageParams.user_arch) - print(f'model is: {model}') + print(f"model is: {model}") optimizer = getOptimizer(model, imageParams.optimizer_name, 0.05) criterionHandler = getCriterionHandler(imageParams.criterion) if imageParams.problem_type == "CLASSIFICATION": diff --git a/training/training/urls.py b/training/training/urls.py index 2e6e6c048..f834bf4f5 100644 --- a/training/training/urls.py +++ b/training/training/urls.py @@ -23,6 +23,7 @@ from training.routes.datasets.default.columns import router as default_dataset_router from training.routes.tabular.tabular import router as tabular_router from training.routes.image.image import router as image_router + # from training.routes.datasets.default import get_default_datasets_router # from training.routes.tabular import get_tabular_router # from training.routes.image import image_router