Aimed at the problems of slow convergence speed, premature maturity, and poor optimization results when the standard genetic algorithm solves the loading plan, based on the anthropomorphic loading strategy, an improved genetic algorithm is proposed to maximize the utilization of container space, considering the loading sequence, volume, and quality of the goods, center of gravity, non-overlapping and other practical constraints. First, the real number code combined with the placement state of the goods is used to randomly generate the initial population. Second, the optimal solution preservation strategy is added to the routine selection operation, and the stability, support constraints, and center of gravity constraints are taken into account after linear scale transformation. In the fitness function, the evaluation value of each loading scheme is calculated by this. Finally, the scheme with the highest evaluation value is output as the optimal loading scheme. In the experimental part, the performance test was performed using test cases with different heterogeneity, and then three sets of specific cargo loading data were combined to prove the universality and practicability of the algorithm. The results show that the proposed algorithm has better optimization effect in solving the process of strong heterogeneous cargo loading, and is suitable for solving the container loading problem. Compared with the standard genetic algorithm, the convergence and search speed have been improved. The space utilization of the two different container types has increased by 3.82% and 3.66%, and the running time has been shortened by 7.9 s and 5.58 s. The optimal loading can be found quickly. The solution can effectively solve the problem of cargo packing in regular and irregular containers. At the same time, the visualization of the loading plan is realized based on MATLAB software, which provides a theoretical basis for the real-time loading decision of the container.