# -*- 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 = None

VERSION = 'FCOS_DIOR_R_2x_20211026'

"""
FCOS
FLOPs: 648349967;    Trainable params: 32101661

cls : storagetank|| Recall: 0.6070801763623133 || Precison: 0.522588252634682|| AP: 0.5675483626328045
F1:0.6402132677945671 P:0.7701612903225806 R:0.5477933307649502
cls : basketballcourt|| Recall: 0.8863000931966449 || Precison: 0.41756311745334795|| AP: 0.8095658009800821
F1:0.8883361555767274 P:0.9429618001046572 R:0.8397017707362535
cls : trainstation|| Recall: 0.6679764243614931 || Precison: 0.1652089407191448|| AP: 0.48575696968464577
F1:0.5751715930586401 P:0.5912863070539419 R:0.5599214145383105
cls : golffield|| Recall: 0.8347826086956521 || Precison: 0.3102779573367809|| AP: 0.7369839267215232
F1:0.782852188239974 P:0.8652631578947368 R:0.7147826086956521
cls : ship|| Recall: 0.766441198203831 || Precison: 0.597205305932635|| AP: 0.6868833844588988
F1:0.7646720743127167 P:0.8294887987768397 R:0.7092593645199795
cls : harbor|| Recall: 0.5262479871175524 || Precison: 0.09804980498049805|| AP: 0.38269377114724834
F1:0.482369309508078 P:0.6320459290187892 R:0.39001610305958134
cls : overpass|| Recall: 0.5544332210998878 || Precison: 0.1566513397811955|| AP: 0.4595486753485633
F1:0.5593875312604917 P:0.7271095152603232 R:0.45454545454545453
cls : airplane|| Recall: 0.580004870920604 || Precison: 0.6662470275563016|| AP: 0.5266901261896053
F1:0.6519157486177687 P:0.8437137330754352 R:0.5311738918655626
cls : airport|| Recall: 0.539039039039039 || Precison: 0.2008953553441522|| AP: 0.36901094209515395
F1:0.508602207723822 P:0.5310457516339869 R:0.487987987987988
cls : Expressway-Service-area|| Recall: 0.7806451612903226 || Precison: 0.3879981676591846|| AP: 0.6922338998833193
F1:0.7675077419216725 P:0.8542372881355932 R:0.6967741935483871
cls : Expressway-toll-station|| Recall: 0.625 || Precison: 0.20398481973434535|| AP: 0.5926291826236693
F1:0.6798159018044566 P:0.8875878220140515 R:0.5508720930232558
cls : windmill|| Recall: 0.733822548365577 || Precison: 0.45643153526970953|| AP: 0.6107706611546414
F1:0.7153514683045422 P:0.7491785323110625 R:0.6844563042028019
cls : tenniscourt|| Recall: 0.8565981206591311 || Precison: 0.6539821168642129|| AP: 0.8002419994662358
F1:0.8522858122728946 P:0.9079291762894535 R:0.8030777611330518
cls : dam|| Recall: 0.42936802973977695 || Precison: 0.09901414487783969|| AP: 0.1962810935479779
F1:0.33497038759138303 P:0.35639412997903563 R:0.3159851301115242
cls : bridge|| Recall: 0.3561220548474314 || Precison: 0.11252135709055407|| AP: 0.25889878429851476
F1:0.34721081838405804 P:0.4652822842310188 R:0.2769409038238702
cls : chimney|| Recall: 0.7701260911736179 || Precison: 0.4061381074168798|| AP: 0.7227722094100086
F1:0.8239153662747865 P:0.96 R:0.7216294859359845
cls : vehicle|| Recall: 0.4182057057057057 || Precison: 0.25272780890592744|| AP: 0.37257660284415944
F1:0.4639285946304213 P:0.6807058310943287 R:0.35187687687687685
cls : baseballfield|| Recall: 0.7300524170064066 || Precison: 0.6493136493136493|| AP: 0.7014549578724086
F1:0.7652096003553635 P:0.891860465116279 R:0.6700640652300525
cls : groundtrackfield|| Recall: 0.893368700265252 || Precison: 0.28364493852113865|| AP: 0.7272457431058066
F1:0.7665548293335653 P:0.7719203873050027 R:0.7612732095490716
cls : stadium|| Recall: 0.6711309523809523 || Precison: 0.3864610111396744|| AP: 0.5669134697747317
F1:0.6345407005975999 P:0.8154205607476636 R:0.5193452380952381
mAP is : 0.563335028162
"""



