Пример #1
0
system["epochs"] = int(system["epochs"])
system["val_interval"] = int(system["val_interval"])
system["lr"] = float(system["lr"])

gtf = Detector()

gtf.Train_Dataset(root_dir,
                  coco_dir,
                  img_dir,
                  set_dir,
                  batch_size=system["batch_size"],
                  image_size=system["image_size"],
                  use_gpu=system["use_gpu"])

if (system["val_data"] == "yes"):
    gtf.Val_Dataset(val_root_dir, val_coco_dir, val_img_dir, val_set_dir)

tmp = system["devices"].split(",")
gpu_devices = []
for i in range(len(tmp)):
    gpu_devices.append(int(tmp[i]))

gtf.Model(gpu_devices=gpu_devices)

gtf.Set_Hyperparams(lr=system["lr"],
                    val_interval=system["val_interval"],
                    es_min_delta=system["es_min_delta"],
                    es_patience=system["es_patience"])

gtf.Train(num_epochs=system["epochs"],
          model_output_dir=system["output_model_dir"])
Пример #2
0
os.chdir("/content/")

troot_dir = "Root_Dir";
tcoco_dir = "Coco_style";
timg_dir = "images";
tset_dir = "Train";



vroot_dir = "Root_Dir";
vcoco_dir = "Coco_style";
vimg_dir = "images";
vset_dir = "Val";

model.Train_Dataset(troot_dir, tcoco_dir, timg_dir, tset_dir, batch_size=8, image_size=352, use_gpu=True)
model.Val_Dataset(vroot_dir, vcoco_dir, vimg_dir, vset_dir)

model.Model(model_name="resnet34"); # resnet 50 brought cuda memory error.
model.Set_Hyperparams(lr=0.0001, val_interval=1, print_interval=20)
model.Train(num_epochs=300,output_model_name="karen_model.pt");

from infer_detector import Infer
gtf = Infer();
gtf.Model(model_path="/content/karen_model.pt");

#predictions are quite bad at the moment.
class_list=[]
with open("/content/Root_Dir/Coco_style/annotations/classes.txt") as file:
  for line in file:
    class_list.append(line.rstrip("\n"))
class_list=class_list[:-1]