## 1 Introduction  
The grape is one of the four major fruits in the world. It has a bright color and delicious taste and is well-liked by consumers. It is an important high-value-added crop in China. Moreover, China is the largest producer and consumer of table grapes [1; 2]. With the increase in the population's consumption level, the demand for high-quality grapes is growing rapidly. Table grapes are mainly harvested and sold in whole bunches. The realization of the rapid, non-destructive detection of the internal quality of bunch-harvested grapes is of great significance for guiding production, improving grape sale profits, and improving the grape grading system [3]. The soluble solids content (SSC) is an important indicator for judging the quality and ripeness of grapes, and it is a determinant of the overall taste and flavor of grapes [4]. Since the SSC of grapes cannot be estimated manually by the naked eye, destructive sampling is often used to assess the ripeness of the entire batch. This method not only requires the destruction of grape berries, causing waste in production, but also has a low efficiency and cannot accurately evaluate the quality of each bunch of grapes; thus, it is difficult to achieve the accurate grading of large quantities in production. In recent years, HSI has gradually been applied for the non-destructive detection of fruits [5], such as tomatoes [6], loquats [7], blueberries [8], red jujubles [9], apples [10], etc. Hyperspectral data can be represented by a \"3D image cube\", which can simultaneously obtain image and spectral information on fruits, as shown in Figure 1. The horizontal and vertical coordinate information of the two-dimensional image is represented by \(x\) and \(y\), respectively. The third dimensional spectral information is represented by \(\lambda\). The detection technology based on HSI uses the reflectance characteristics of the target object in regard to different spectra to predict the internal characteristics of the target. Related studies on the non-destructive detection of the internal quality of grapes have been conducted. In current research on hyperspectral imaging, line-scan spectroscopy (pushbroom) and point spectroscopy (whiskbroom) are mainly used. In these studies, relatively accurate prediction models for SSC have been established. In research using line-scan spectroscopy [11; 12; 13; 14], the reflectance spectrum of multiple grapes can be obtained in one image, but the methods require the manual selection of the Region of Interest (RoI) to obtain the average spectral reflectance, which cannot be automatically detected in batches. In research using point spectroscopy [15; 16], the reflectance spectrum of one grape can be obtained each time; still, this one-by-one detection method has a low efficiency. Therefore, the applicability of current research is limited: for example, non-destructive detection of a small amount of grape berries in the laboratory. To achieve the non-destructive detection of every single grape berry in order to accurately grade the quality of grape bunches, a large amount of time would be required. Aiming to address the defects of the existing non-destructive detection technology based on HSI, in this article we propose an improved method. By combining the existing method with target recognition and image segmentation technology based on DL, we extracted the texture feature information in the image to establish an accurate model to identify and segment grapes [17]. In this way, the RoI can be extracted automatically and efficiently so as to obtain the average spectral reflectance of each grape. In this study, the existing non-destructive detection method for grape SSC based on near-infrared hyperspectral (400-1000 nm) images was improved.