update template code
This commit is contained in:
0
mmp/a3/__init__.py
Normal file
0
mmp/a3/__init__.py
Normal file
27
mmp/a3/annotation.py
Normal file
27
mmp/a3/annotation.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import List
|
||||
import numpy as np
|
||||
|
||||
|
||||
class AnnotationRect:
|
||||
"""Exercise 3.1"""
|
||||
|
||||
def __init__(self, x1, y1, x2, y2):
|
||||
raise NotImplementedError()
|
||||
|
||||
def area(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def __array__(self) -> np.ndarray:
|
||||
raise NotImplementedError()
|
||||
|
||||
@staticmethod
|
||||
def fromarray(arr: np.ndarray):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def read_groundtruth_file(path: str) -> List[AnnotationRect]:
|
||||
"""Exercise 3.1b"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
# put your solution for exercise 3.1c wherever you deem it right
|
||||
29
mmp/a3/dataset.py
Normal file
29
mmp/a3/dataset.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Tuple
|
||||
import torch
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
|
||||
class MMP_Dataset(torch.utils.data.Dataset):
|
||||
"""Exercise 3.2"""
|
||||
|
||||
def __init__(self, path_to_data: str, image_size: int):
|
||||
"""
|
||||
@param path_to_data: Path to the folder that contains the images and annotation files, e.g. dataset_mmp/train
|
||||
@param image_size: Desired image size that this dataset should return
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def __getitem__(self, idx: int) -> Tuple[torch.Tensor, int]:
|
||||
"""
|
||||
@return: Tuple of image tensor and label. The label is 0 if there is one person and 1 if there a multiple people.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def __len__(self) -> int:
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_dataloader(
|
||||
path_to_data: str, image_size: int, batch_size: int, num_workers: int, is_train: bool = True
|
||||
) -> DataLoader:
|
||||
|
||||
"""Exercise 3.2d"""
|
||||
7
mmp/a3/main.py
Normal file
7
mmp/a3/main.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def main():
|
||||
"""Put your code for Exercise 3.3 in here"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user