Browse Source

Change directory structure

v1
Teoge 6 years ago
parent
commit
b3d7c0b0f7
13 changed files with 27 additions and 28 deletions
  1. +6
    -0
      data/__init__.py
  2. +2
    -5
      data/data_process.py
  3. +2
    -2
      data/dataset.py
  4. +5
    -8
      evaluate.py
  5. +3
    -3
      inference.py
  6. +0
    -0
      model/__init__.py
  7. +2
    -2
      model/detector.py
  8. +1
    -1
      model/network.py
  9. +0
    -0
      prepare_dataset.py
  10. +5
    -6
      train.py
  11. +0
    -0
      util/__init__.py
  12. +0
    -0
      util/log.py
  13. +1
    -1
      util/precision_recall.py

+ 6
- 0
data/__init__.py View File

@@ -0,0 +1,6 @@
"""Defines data structure and related functions."""
from collections import namedtuple


MarkingPoint = namedtuple('MarkingPoint', ['x', 'y', 'direction', 'shape'])
Slot = namedtuple('Slot', ['x1', 'y1', 'x2', 'y2'])

data.py → data/data_process.py View File

@@ -1,11 +1,8 @@
from collections import namedtuple
"""Defines data structure and related function to process these data."""
import math
import torch
import config


MarkingPoint = namedtuple('MarkingPoint', ['x', 'y', 'direction', 'shape'])
Slot = namedtuple('Slot', ['x1', 'y1', 'x2', 'y2'])
from . import MarkingPoint


def generate_objective(marking_points_batch, device):

dataset.py → data/dataset.py View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
"""Defines the parking slot dataset for directional marking point detection."""
import json
import os
import os.path
import cv2 as cv
from torch.utils.data import Dataset
from torchvision import transforms
from data import MarkingPoint
from . import MarkingPoint


class ParkingSlotDataset(Dataset):

+ 5
- 8
evaluate.py View File

@@ -1,15 +1,12 @@
"""Evaluate directional marking point detector."""
import torch
from torch.utils.data import DataLoader
from precision_recall import calc_average_precision
from precision_recall import calc_precision_recall
import config
from data import generate_objective
from data import get_predicted_points
from data import match_marking_points
from dataset import ParkingSlotDataset
from detector import DirectionalPointDetector
from log import Logger
from data.data_process import generate_objective, get_predicted_points, match_marking_points
from data.dataset import ParkingSlotDataset
from model.detector import DirectionalPointDetector
from util.log import Logger
from util.precision_recall import calc_average_precision, calc_precision_recall


def evaluate_detector(args):

+ 3
- 3
inference.py View File

@@ -5,9 +5,9 @@ import numpy as np
import torch
from torchvision.transforms import ToTensor
import config
from data import get_predicted_points
from detector import DirectionalPointDetector
from utils import Timer
from data.data_process import get_predicted_points
from model.detector import DirectionalPointDetector
from util import Timer


def plot_marking_points(image, marking_points):

+ 0
- 0
model/__init__.py View File


detector.py → model/detector.py View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Defines the detector network structure."""
import torch
from torch import nn
from network import define_halve_unit, define_detector_block
from model.network import define_halve_unit, define_detector_block


class YetAnotherDarknet(nn.modules.Module):

network.py → model/network.py View File

@@ -1,4 +1,4 @@
"""Common network struture unit definition."""
"""Universal network struture unit definition."""
from torch import nn



scripts/prepare_dataset.py → prepare_dataset.py View File


+ 5
- 6
train.py View File

@@ -3,12 +3,11 @@ import random
import torch
from torch.utils.data import DataLoader
import config
from data import get_predicted_points
from data import generate_objective
from dataset import ParkingSlotDataset
from detector import DirectionalPointDetector
from log import Logger
from utils import tensor2im
from data.data_process import get_predicted_points, generate_objective
from data.dataset import ParkingSlotDataset
from model.detector import DirectionalPointDetector
from util.log import Logger
from util import tensor2im


def plot_prediction(logger, image, marking_points, prediction):

utils.py → util/__init__.py View File


log.py → util/log.py View File


precision_recall.py → util/precision_recall.py View File

@@ -1,4 +1,4 @@
"""Universal procedure of calculating average precision defined in VOC"""
"""Universal procedure of calculating precision and recall."""


def match_gt_with_preds(ground_truth, predictions, match_labels):

Loading…
Cancel
Save