Intelligent logistics and freight transportation is an important part of realizing the intelligence of port terminals. Due to the problems of inaccurate ton bag identification, high costs, large model sizes, and long computation times in traditional freight transportation—issues that hinder meeting real-time requirements on resource-constrained operational equipment—this paper proposes an improved lightweight ton bag detection algorithm, YOLOv8-TB (YOLOv8-Ton Bag), which is optimized based on YOLOv8. Firstly, the improved LZKAC module is introduced to combine with SPPF to form a new SPPFLKZ module, which improves the feature expression performance. Then, with reference to spatial and channel reconstruction convolution and deformable convolution, the C2f-SCTT block is designed for the backbone network, which reduces the spatial and channel redundancy between features in the network. Finally, the C2f-ORECZ block based on a linear scaling layer is designed for the neck, which reduces the training overhead and strengthens the feature learning of the feature extraction network for the targets in the complex background of the harbor and adds the 160 × 160 scale detection head to strengthen small target detection abilities. On the logistics ton bag operation dataset provided by shipping port enterprises, the improved algorithm improves by 3.7% and 5% compared with the original algorithm in mAP50 and mAP50-95, respectively, the model size is reduced by 4.42 MB and the amount of model computation is only 8 G, which is capable of accurately detecting logistics ton bags in real time. The superiority of the method is verified by comparing it with other classical target detection algorithms.