This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 모델에 쓸 파라미터를 정의 | |
| params = { | |
| 'num_classes': num_classes, # 카테고리 수 | |
| 'log_path': 'log/', # 로그 파일 저장 경로 | |
| 'cp_path': 'checkpoint/', # 모델 체크포인트 저장 경로 | |
| 'model_path': 'model/', # 최종 모델 저장 경로 | |
| 'mode': 'fe', # 훈련 모드 (fe: feature extraction, ft: finetuning) | |
| 'lr': 0.001, # learning rate | |
| 'epoch': 10, # 훈련 epoch | |
| 'network_params': { # applications 모듈로 불러들일 네트워크 파라미터 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tensorflow.python.keras.metrics import top_k_categorical_accuracy | |
| from tensorflow.python.keras.optimizers import Adam | |
| from sklearn.utils.class_weight import compute_class_weight | |
| class Model(): | |
| ... | |
| def train(self): | |
| if self.trained == True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tensorflow.python.keras.preprocessing.image import ImageDataGenerator | |
| TRAIN_PATH = "training/" | |
| batch_size = 128 | |
| input_shape = (224, 224) | |
| datagen = ImageDatagenerator(rescale=1./255, validation_split=0.1) | |
| generator_train = datagen.flow_from_directory(directory=TRAIN_PATH, | |
| target_size=input_shape, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tensorflow.python.keras.applications import InceptionV3, Xception | |
| from tensorflow.python.keras.models import Sequential | |
| from tensorflow.python.keras.layers import Dense, GlobalAveragePooling2D | |
| class Model(): | |
| def __init__(self, name, class_weight, params): | |
| assert name != '', "Model name needs to be specified" | |
| self.name = name | |
| self.trained = False | |