Skip to content

Commit

Permalink
Chor: fine tunning for trainning
Browse files Browse the repository at this point in the history
  • Loading branch information
zaiyou12 committed Nov 1, 2018
1 parent d7d600a commit 9a4fd9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
32 changes: 13 additions & 19 deletions dish.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ class DishConfig(Config):

# We use a GPU with 12GB memory, which can fit two images.
# Adjust down if you use a smaller GPU.
IMAGES_PER_GPU = 2
GPU_COUNT = 1
IMAGES_PER_GPU = 1

# Number of training and validation steps per epoch
STEPS_PER_EPOCH = 1000
STEPS_PER_EPOCH = 2000
VALIDATION_STEPS = 100

# Backbone network architecture
Expand Down Expand Up @@ -111,7 +112,7 @@ class DishConfig(Config):
DETECTION_MAX_INSTANCES = 200

# Skip detections with < 50% confidence
DETECTION_MIN_CONFIDENCE = 0.5
DETECTION_MIN_CONFIDENCE = 0

def add_args(self, **kwargs):
self.__dict__.update(kwargs)
Expand Down Expand Up @@ -252,8 +253,7 @@ def train(model):
iaa.Affine(rotate=270),
iaa.Affine(rotate=45),
iaa.Affine(rotate=135)]),
iaa.Multiply((0.8, 1.5)),
iaa.GaussianBlur(sigma=(0.0, 5.0))
iaa.Multiply((0.8, 1.5))
])

# *** This training schedule is an example. Update to your needs ***
Expand All @@ -270,16 +270,10 @@ def train(model):
print("Fine tune Resnet stage 4 and up")
model.train(dataset_train, dataset_val,
learning_rate=config.LEARNING_RATE,
epochs=40,
epochs=100,
layers='4+',
augmentation=augmentation)

model.train(dataset_train, dataset_val,
learning_rate=config.LEARNING_RATE/10,
epochs=80,
layers='all',
augmentation=augmentation)


def color_splash(image, mask):
"""Apply color splash effect.
Expand Down Expand Up @@ -381,11 +375,11 @@ def detect_and_color_splash(model, image_path=None, video_path=None):
parser.add_argument('--video', required=False,
metavar="path or URL to video",
help='Video to apply the color splash effect on')
parser.add_argument('--pairs', required=False,
metavar="key=value",
help="Key values to apply config",
action='append',
type=lambda kv: kv.split("="))
# parser.add_argument('--pairs', required=False,
# metavar="key=value",
# help="Key values to apply config",
# action='append',
# type=lambda kv: kv.split("="))
args = parser.parse_args()

# Validate arguments
Expand All @@ -403,10 +397,10 @@ def detect_and_color_splash(model, image_path=None, video_path=None):
# Configurations
if args.command == "train":
dish_config = DishConfig()
dish_config.add_args(**dict(args.pairs))
# dish_config.add_args(**dict(args.pairs))
config = dish_config
else:
config = DishIngerenceConfig()
config = DishInferenceConfig()
config.display()

# Create model
Expand Down
7 changes: 4 additions & 3 deletions retrain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ ssh ${SERVER_NAME}
rm -rf logs
vim dish.py

## Change something if u want
## vim dish.py
## Change something if you want
## $ vim dish.py
## when in parell mode you must use 'keras==2.0.8'
tmux new -s train

source activate tensorflow_p36
pip install imgaug opencv-python
python3 dish.py train --dataset=${PWD}/data --weights=coco --pairs BACKBONE=resnet101
python3 dish.py train --dataset=${PWD}/data --weights=coco --pairs BACKBONE=resnet101

0 comments on commit 9a4fd9b

Please sign in to comment.