stevfoy commited on
Commit
7fc6dc6
·
1 Parent(s): b5a1549
Files changed (4) hide show
  1. app.py +1 -1
  2. config.py +1 -1
  3. main_yolov3_lightening.py +1 -1
  4. pytorchyolo/models.py +15 -0
app.py CHANGED
@@ -33,7 +33,7 @@ model = YOLOv3Lightning()
33
  model.load_state_dict(torch.load("yolov3_608_ckpt_40.pth", map_location=torch.device('cpu')), strict=False)
34
  model.setup(stage="test")
35
 
36
- IMAGE_SIZE = 416
37
  transforms = A.Compose(
38
  [
39
  A.LongestMaxSize(max_size=IMAGE_SIZE),
 
33
  model.load_state_dict(torch.load("yolov3_608_ckpt_40.pth", map_location=torch.device('cpu')), strict=False)
34
  model.setup(stage="test")
35
 
36
+ IMAGE_SIZE = 608
37
  transforms = A.Compose(
38
  [
39
  A.LongestMaxSize(max_size=IMAGE_SIZE),
config.py CHANGED
@@ -10,7 +10,7 @@ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
10
  # seed_everything() # If you want deterministic behavior
11
  NUM_WORKERS = 4
12
  BATCH_SIZE = 16
13
- IMAGE_SIZE = 416
14
  NUM_CLASSES = 1
15
  LEARNING_RATE = 1e-5
16
  WEIGHT_DECAY = 1e-4
 
10
  # seed_everything() # If you want deterministic behavior
11
  NUM_WORKERS = 4
12
  BATCH_SIZE = 16
13
+ IMAGE_SIZE = 608
14
  NUM_CLASSES = 1
15
  LEARNING_RATE = 1e-5
16
  WEIGHT_DECAY = 1e-4
main_yolov3_lightening.py CHANGED
@@ -22,7 +22,7 @@ class YOLOv3Lightning(pl.LightningModule):
22
  super().__init__()
23
  self.config = config
24
  #self.model = YOLOv3(num_classes=self.config.NUM_CLASSES)
25
- self.model = load_model("yolov3_divots_608.cfg", "yolov3_608_ckpt_40.pth")
26
  self.loss_fn = YoloLoss()
27
  if lr_value == 0:
28
  self.learning_rate = self.config.LEARNING_RATE
 
22
  super().__init__()
23
  self.config = config
24
  #self.model = YOLOv3(num_classes=self.config.NUM_CLASSES)
25
+ self.model = load_model("yolov3_divots_608.cfg")
26
  self.loss_fn = YoloLoss()
27
  if lr_value == 0:
28
  self.learning_rate = self.config.LEARNING_RATE
pytorchyolo/models.py CHANGED
@@ -316,7 +316,22 @@ class Darknet(nn.Module):
316
 
317
  fp.close()
318
 
 
 
319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  def load_model(model_path, weights_path=None):
321
  """Loads the yolo model from file.
322
 
 
316
 
317
  fp.close()
318
 
319
+ def load_model(model_path):
320
+ """Loads the yolo model from file.
321
 
322
+ :param model_path: Path to model definition file (.cfg)
323
+ :type model_path: str
324
+ :param weights_path: Path to weights or checkpoint file (.weights or .pth)
325
+ :type weights_path: str
326
+ :return: Returns model
327
+ :rtype: Darknet
328
+ """
329
+ device = torch.device("cuda" if torch.cuda.is_available()
330
+ else "cpu") # Select device for inference
331
+ model = Darknet(model_path).to(device)
332
+
333
+ return model
334
+
335
  def load_model(model_path, weights_path=None):
336
  """Loads the yolo model from file.
337