This repository has been archived on 2022-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
mmp-osp1/docs/report/Appendices/appendixB.tex
Oscar Pocock 523f518aa8
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/test Pipeline failed
Final submission commit
A few changes:
- Added report
- Added mid project demo content
- Added README.txt
- Added Experiments
- Added ratings.txt file
- Added unit tests
- Simplified the prediction code
- Added single prediction
2022-05-14 17:44:05 +01:00

90 lines
2.9 KiB
TeX
Executable file

\chapter{Code Examples}
%For some projects, it might be relevant to include some code extracts in an appendix. You are not expected to put all of your code here - the correct place for all of your code is in the technical submission that is made in addition to the Project Report. However, if there are some notable aspects of the code that you discuss, including that in an appendix might be useful to make it easier for your readers to access.
%
%As a general guide, if you are discussing short extracts of code then you are advised to include such code in the body of the report. If there is a longer extract that is relevant, then you might include it as shown in the following section.
%
%Only include code in the appendix if that code is discussed and referred to in the body of the report.
\section{Woodpecker pipelines}
\subsection{Lint pipeline}
The lint pipeline was use to automatically report back on any linting issues with the code after a commit.
\begin{verbatim}
pipeline:
flake8:
image: python:3.8
commands:
- python3.8 -m pip install flake8
- flake8 src/
mypy:
image: python:3.8
commands:
- python3.8 -m pip install mypy
- mypy src/
isort:
image: python:3.8
commands:
- python3.8 -m pip install isort
- isort --diff src/
branches: dev
\end{verbatim}
\subsection{Test pipeline}
\begin{verbatim}
pipeline:
unit-tests:
image: python:3.8
commands:
- apt update -y && apt install libgl1 -y
- python3.8 -m pip install -r ./requirements.txt
- python3.8 -m pip install -r ./requirements_dev.txt
- python3.8 -m pip install -e .
- pytest test/ -v
branches: dev
\end{verbatim}
\subsection{Configuration file}\label{config file}
\begin{verbatim}
---
# Configuration file for the autophographer tool
# List of filters to apply in order
# Note: Possible filters include: brightness, filesize, contrast, focus
filters:
- brightness
- filesize
- contrast
- focus
# Whether or not to apply CNN ranking
CNNrank: False
# Ignore video files and don't bother processing them into frames
# Note: Useful if directory contains original video and indivual
# frames from video (prevents processing the same frames more than once)
ignore_video: True
# Options for brightness filter
brightness_options:
threshold: 0.25
# Options for filesize filter
filesize_options:
threshold: 0.35
# Options for contrast filter
contrast_options:
threshold: 0.35
# Options for focus filter
focus_options:
threshold: 0.5
...
\end{verbatim}
\subsection{pil\_loader() method}
This method was taken from a GitHub issue comment \href{https://github.com/python-pillow/Pillow/issues/835\#issuecomment-53999355}{https://github.com/python-pillow/Pillow/issues/835\#issuecomment-53999355}
\begin{verbatim}
def pil_loader(path):
with open(path, 'rb') as f:
image = Image.open(f)
return image.convert('RGB')
\end{verbatim}