scales annotations
@@ -20,6 +20,12 @@ class AnnotationRect:
|
||||
def __array__(self) -> np.ndarray:
|
||||
return np.array([self.x1, self.y1, self.x2, self.y2])
|
||||
|
||||
def scale(self, factor: float):
|
||||
self.x1 *= factor
|
||||
self.x2 *= factor
|
||||
self.y1 *= factor
|
||||
self.y2 *= factor
|
||||
|
||||
@staticmethod
|
||||
def fromarray(arr: np.ndarray):
|
||||
return AnnotationRect(arr[0], arr[1], arr[2], arr[3])
|
||||
|
||||
|
Before Width: | Height: | Size: 504 KiB |
|
Before Width: | Height: | Size: 69 KiB |
BIN
mmp/a4/2243119_original.png
Normal file
|
After Width: | Height: | Size: 285 KiB |
BIN
mmp/a4/2243119_transformed.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 159 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 175 KiB |
|
Before Width: | Height: | Size: 53 KiB |
BIN
mmp/a4/2244764_original.png
Normal file
|
After Width: | Height: | Size: 429 KiB |
BIN
mmp/a4/2244764_transformed.png
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
mmp/a4/2244924_original.png
Normal file
|
After Width: | Height: | Size: 141 KiB |
BIN
mmp/a4/2244924_transformed.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 248 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 81 KiB |
BIN
mmp/a4/2250234_original.png
Normal file
|
After Width: | Height: | Size: 252 KiB |
BIN
mmp/a4/2250234_transformed.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 385 KiB |
|
Before Width: | Height: | Size: 92 KiB |
BIN
mmp/a4/2251430_original.png
Normal file
|
After Width: | Height: | Size: 192 KiB |
BIN
mmp/a4/2251430_transformed.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 892 KiB |
|
Before Width: | Height: | Size: 60 KiB |
BIN
mmp/a4/2254610_original.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
mmp/a4/2254610_transformed.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
mmp/a4/2256266_original.png
Normal file
|
After Width: | Height: | Size: 243 KiB |
BIN
mmp/a4/2256266_transformed.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 189 KiB |
|
Before Width: | Height: | Size: 46 KiB |
BIN
mmp/a4/2256880_original.png
Normal file
|
After Width: | Height: | Size: 432 KiB |
BIN
mmp/a4/2256880_transformed.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
mmp/a4/2258993_original.png
Normal file
|
After Width: | Height: | Size: 234 KiB |
BIN
mmp/a4/2258993_transformed.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 59 KiB |
BIN
mmp/a4/2260471_original.png
Normal file
|
After Width: | Height: | Size: 274 KiB |
BIN
mmp/a4/2260471_transformed.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
mmp/a4/2261564_original.png
Normal file
|
After Width: | Height: | Size: 349 KiB |
BIN
mmp/a4/2261564_transformed.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
mmp/a4/2262264_original.png
Normal file
|
After Width: | Height: | Size: 257 KiB |
BIN
mmp/a4/2262264_transformed.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 394 KiB |
|
Before Width: | Height: | Size: 67 KiB |
@@ -29,7 +29,7 @@ class MMP_Dataset(torch.utils.data.Dataset):
|
||||
@param is_test: Whether this is the test set (True) or the validation/training set (False)
|
||||
"""
|
||||
self.image_size = image_size
|
||||
self.images = []
|
||||
self.images: Sequence[Tuple[str, Sequence[AnnotationRect]]] = []
|
||||
self.anchor_grid = anchor_grid
|
||||
self.min_iou = min_iou
|
||||
self.is_test = is_test
|
||||
@@ -72,8 +72,14 @@ class MMP_Dataset(torch.utils.data.Dataset):
|
||||
img_id = re.match(r".*(\/)([0-9]+)(\.[^\/]*$)", self.images[idx][0]).group(2)
|
||||
if self.is_test:
|
||||
return (img_tensor, torch.Tensor(), int(img_id))
|
||||
|
||||
scaled_annotations = []
|
||||
for annotation in self.images[idx][1]:
|
||||
annotation.scale(self.image_size / max(img.size[0], img.size[1]))
|
||||
scaled_annotations.append(annotation)
|
||||
|
||||
label_grid = get_label_grid(
|
||||
anchor_grid=self.anchor_grid, gts=self.images[idx][1], min_iou=self.min_iou
|
||||
anchor_grid=self.anchor_grid, gts=scaled_annotations, min_iou=self.min_iou
|
||||
)
|
||||
return (img_tensor, label_grid, int(img_id))
|
||||
|
||||
|
||||
BIN
mmp/a4/document.pdf
Normal file
70
mmp/a4/document.tex
Normal file
@@ -0,0 +1,70 @@
|
||||
\documentclass[11pt,a4paper]{article}
|
||||
|
||||
% Language and encoding settings
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[english]{babel}
|
||||
|
||||
% Page formatting
|
||||
\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}
|
||||
\usepackage{setspace}
|
||||
\onehalfspacing
|
||||
|
||||
% Header/Footer
|
||||
\usepackage{fancyhdr}
|
||||
\pagestyle{fancy}
|
||||
\fancyhf{} % clear all header and footer fields
|
||||
\fancyhead[L]{\textbf{\course}}
|
||||
\fancyhead[C]{Assignment \assignmentnumber}
|
||||
\fancyhead[R]{\name}
|
||||
\fancyfoot[C]{\thepage}
|
||||
|
||||
% Other packages
|
||||
\usepackage{enumitem}
|
||||
\usepackage{graphicx}
|
||||
|
||||
% Custom commands for easy detail insertion
|
||||
\newcommand{\assignmentnumber}{04} % <-- CHANGE Assignment Number
|
||||
\newcommand{\name}{Simon Franken} % <-- CHANGE YOUR NAME
|
||||
\newcommand{\course}{Multimedia Project WiSe 2526} % <-- CHANGE COURSE NAME
|
||||
\newcommand{\duedate}{2025-11-12} % <-- CHANGE DUE DATE
|
||||
|
||||
% Title formatting
|
||||
\usepackage{titling}
|
||||
\pretitle{
|
||||
\vspace*{2cm}
|
||||
\begin{center}
|
||||
\LARGE\bfseries
|
||||
}
|
||||
\posttitle{\par\end{center}\vspace{1cm}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\title{Assignment \assignmentnumber}
|
||||
\author{\name}
|
||||
\date{\duedate}
|
||||
|
||||
\maketitle
|
||||
|
||||
\begin{center}
|
||||
\textbf{Course:} \course
|
||||
\end{center}
|
||||
\vspace{0.5cm}
|
||||
|
||||
%------------------ START OF ASSIGNMENT -----------------------
|
||||
|
||||
% Write your solutions below
|
||||
|
||||
\section*{Exercise 4.2 Label Grid}
|
||||
\begin{enumerate}[label=\alph*)]
|
||||
\setcounter{enumi}{2}
|
||||
\item \begin{figure}[htp]
|
||||
\centering
|
||||
\includegraphics[width=4cm]{output.jpg}
|
||||
\caption{output.txt}
|
||||
\end{figure}
|
||||
\end{enumerate}
|
||||
|
||||
%------------------ END OF ASSIGNMENT -----------------------
|
||||
|
||||
\end{document}
|
||||