# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import

import numpy as np

from alpharotate.utils.pretrain_zoo import PretrainModelZoo
from configs._base_.models.retinanet_r50_fpn import *
from configs._base_.datasets.dota_detection import *
from configs._base_.schedules.schedule_1x import *

# schedule
BATCH_SIZE = 1
GPU_GROUP = "0,1"
NUM_GPU = len(GPU_GROUP.strip().split(','))
LR = 1e-3 * BATCH_SIZE * NUM_GPU
SAVE_WEIGHTS_INTE = 11725 * 2
DECAY_EPOCH = [8, 11, 20]
MAX_EPOCH = 12
WARM_EPOCH = 1 / 16.
DECAY_STEP = np.array(DECAY_EPOCH, np.int32) * SAVE_WEIGHTS_INTE
MAX_ITERATION = SAVE_WEIGHTS_INTE * MAX_EPOCH
WARM_SETP = int(WARM_EPOCH * SAVE_WEIGHTS_INTE)

# dataset
DATASET_NAME = 'DIOR-R'
CLASS_NUM = 20

# model
# backbone
pretrain_zoo = PretrainModelZoo()
PRETRAINED_CKPT = pretrain_zoo.pretrain_weight_path(NET_NAME, ROOT_PATH)
TRAINED_CKPT = os.path.join(ROOT_PATH, 'output/trained_weights')

# loss
CLS_WEIGHT = 1.0
REG_WEIGHT = 1.0
CTR_WEIGHT = 1.0
REG_LOSS_MODE = 0

VERSION = 'FCOS_DIOR_R_2x_20211027'

"""
FCOS + modulated loss
cls : groundtrackfield|| Recall: 0.8827586206896552 || Precison: 0.3186518575258522|| AP: 0.7270550962327054
F1:0.7655607844988116 P:0.7816473189607518 R:0.750132625994695
cls : stadium|| Recall: 0.6622023809523809 || Precison: 0.4573484069886948|| AP: 0.5792132835151115
F1:0.6539369752821355 P:0.7392120075046904 R:0.5863095238095238
cls : tenniscourt|| Recall: 0.8578237777475146 || Precison: 0.6628433126381142|| AP: 0.7948234822463487
F1:0.8436131749088985 P:0.888136103583258 R:0.8033501293749149
cls : Expressway-toll-station|| Recall: 0.6308139534883721 || Precison: 0.2129538763493621|| AP: 0.5982980688718281
F1:0.6621572936807917 P:0.7903225806451613 R:0.5697674418604651
cls : airport|| Recall: 0.539039039039039 || Precison: 0.2190359975594875|| AP: 0.35966326207390176
F1:0.5097682689943264 P:0.531810766721044 R:0.4894894894894895
cls : storagetank|| Recall: 0.5956080647232567 || Precison: 0.5781600598354525|| AP: 0.5117297194048891
F1:0.6316270887492599 P:0.766477307433877 R:0.5371345404734387
cls : golffield|| Recall: 0.8034782608695652 || Precison: 0.35|| AP: 0.7398757023217727
F1:0.7931313666872757 P:0.8776371308016878 R:0.7234782608695652
cls : chimney|| Recall: 0.7623666343355965 || Precison: 0.512720156555773|| AP: 0.7220312486065541
F1:0.817376828269523 P:0.9440914866581956 R:0.7206595538312318
cls : windmill|| Recall: 0.7441627751834556 || Precison: 0.5017993702204229|| AP: 0.6264271845000785
F1:0.7302089595158516 P:0.7629952744456562 R:0.700133422281521
cls : bridge|| Recall: 0.35843955195056004 || Precison: 0.11938762382606458|| AP: 0.25745727291807874
F1:0.3467300429760792 P:0.4352392065344224 R:0.2881421398223252
cls : vehicle|| Recall: 0.4173048048048048 || Precison: 0.2795041987227837|| AP: 0.38015630378811294
F1:0.4690048197461466 P:0.681723817023409 R:0.35746996996997
cls : harbor|| Recall: 0.5307568438003221 || Precison: 0.12002913328477786|| AP: 0.3852564942036945
F1:0.4873028809831549 P:0.6047732696897374 R:0.40805152979066023
cls : dam|| Recall: 0.44423791821561337 || Precison: 0.12870220786214323|| AP: 0.24841695128125763
F1:0.3761144280057081 P:0.40471092077087795 R:0.3513011152416357
cls : overpass|| Recall: 0.5331088664421998 || Precison: 0.17921146953405018|| AP: 0.4446274903843719
F1:0.5421597963314636 P:0.6922406277244987 R:0.44556677890011226
cls : basketballcourt|| Recall: 0.8793103448275862 || Precison: 0.5148703956343793|| AP: 0.8107686004040154
F1:0.8908996471504619 P:0.9399896533885153 R:0.8466915191053123
cls : trainstation|| Recall: 0.6620825147347741 || Precison: 0.30415162454873645|| AP: 0.5266084894693088
F1:0.6307808371022694 P:0.6976190476190476 R:0.5756385068762279
cls : baseballfield|| Recall: 0.7201514269073966 || Precison: 0.6846622369878184|| AP: 0.6994357410338342
F1:0.7629027472383607 P:0.9152404237978811 R:0.6540477577169481
cls : airplane|| Recall: 0.6104481246955674 || Precison: 0.669113721302723|| AP: 0.5978083144948587
F1:0.6730216996176209 P:0.8371376811594203 R:0.5627131027764247
cls : ship|| Recall: 0.7718979139430455 || Precison: 0.6119460153662438|| AP: 0.6891525826898209
F1:0.7675632635655041 P:0.8345126835781042 R:0.710566702665833
cls : Expressway-Service-area|| Recall: 0.7751152073732719 || Precison: 0.43106099436186573|| AP: 0.6888664225601235
F1:0.7801078257175024 P:0.8787528868360277 R:0.7013824884792627
mAP is : 0.5693835855500333
"""



