  Reflected or scattered light produce artefacts in astronomical observations
that can negatively impact the scientific study. Hence, automated detection of
these artefacts is highly beneficial, especially with the increasing amounts of
data gathered. Machine learning methods are well-suited to this problem, but
currently there is a lack of annotated data to train such approaches to detect
artefacts in astronomical observations. In this work, we present a dataset of
images from the XMM-Newton space telescope Optical Monitoring camera showing
different types of artefacts. We hand-annotated a sample of 1000 images with
artefacts which we use to train automated ML methods. We further demonstrate
techniques tailored for accurate detection and masking of artefacts using
instance segmentation. We adopt a hybrid approach, combining knowledge from
both convolutional neural networks (CNNs) and transformer-based models and use
their advantages in segmentation. The presented method and dataset will advance
artefact detection in astronomical observations by providing a reproducible
baseline. All code and data are made available
(https://github.com/ESA-Datalabs/XAMI-model and
https://github.com/ESA-Datalabs/XAMI-dataset).
