## 1 Introduction  
Agriculture plays a vital role in the economy of Pakistan, contributing to around 23.13% of the GDP [1]. It employs 43.5% of the workforce and contributes significantly to the country's socioeconomic development [2]. A variety of biotic and abiotic factors limit crop yields around the world [3]. The most damaging biotic constraints to agricultural production are weeds. It competes with crops for moisture, nutrients, and sunlight, which ultimately reduces crop yield [3]. Global grain production is currently 2.1 billion tons. Weeds cause a 10% decrease in overall yield each year [4]. Depending on their species and densities, weeds cause an average yield loss of 11.5% in Pakistan, which is over PKR 65 billion annually [5]. Although traditional weed removal technology is playing its role in the control of weeds in agricultural fields [6]. Weeds can reduce production by more than 90% if they are not controlled. When traditional weed removal technology is used, grain production losses average 10-15% [7]. However, they have raised significant concerns because of their impact on the environment and their labor-intensive nature [8]. In chemical-based weed control, a single pesticide dose is sprayed over the entire field, uniformly covering the soil, crops, and weeds [9]. This widespread and uniform application of herbicides not only causes air pollution but also enters human and animal bodies through the food chain [10], therefore causing significant ecological and health damage. Glyphosate, a widely used herbicide, has been classified as carcinogenic for humans by the World Health Organization (WHO) in 2015 [6]. Assessing the damage caused by chemical weeding technology, there is a pressing need to create a robust weed management system that is efficient, cost-effective, and environmentally friendly [11]. Artificial intelligence has revolutionized several industries, including agriculture, since the start of the Fourth Industrial Revolution [12]. Many advanced, nondestructive techniques for agricultural field management have been developed [13]. Presently, computer vision and global positioning system (GPS) technology are used to perform many agriculture tasks smartly [14]. Some of these are crop yield prediction, plant disease detection, species identification, water, and soil conservation. As a result, variable rate input applications and precise and timely field action are now possible [15]. Recently, deep learning (DL) techniques have been used to detect weeds within and between crop rows. Weed detection and classification are complicated by the fact that in their early stages, weeds and crops have extremely similar colors and textures [16]. ML-based systems are being proposed to distinguish crops from weeds in real time. These systems help to control weeds effectively, but they cannot be fully adopted by a grass-roots farmer until low-cost, precise weed-detection systems are developed [17]. Crop damage can result from poor precision [18]. Machine learning algorithms extract features from input data, such as shape, texture, and color [19]. Conventional ML techniques need substantial domain knowledge to construct a feature extractor based on the shape and texture associated with each type of weed [20]. The deep learning approach on the other hand, employs a representational learning method [21]. In DL, a machine recognizes discriminative features from input data and extracts the features that are best for automatic classification and object detection tasks [22]. Due to their strong feature learning abilities, DL algorithms have a number of advantages over typical machine learning methods. Convolutional neural networks (CNNs) and recurrent neural networks (RNNs) are two commonly used and high-performing network architectures available in DL [22]. CNN is built on a stack of convolutional layers. Each layer takes in the incoming data, transforms or convolves it, and then sends it to the next layer [23].