The embodiments of the present application provide a method for replacing a virtual hairstyle, an electronic device, and a storage medium. In the method for replacing a virtual hairstyle provided in the embodiments of the present application, the hair area of the user is
cut out from the first image containing the user's avatar, and then the missing
scalp area in the first image after the hair is
cut is filled, and then the user's head image after the virtual hairstyle is replaced is determined based on the virtual hairstyle
model image and the first image after the
scalp area is filled, thereby avoiding interference between the virtual hairstyle
model image and the user's hair area during the user's virtual hairstyle trial, thereby improving the user's trial experience. At the same time, by filling the missing
scalp area in the first image after the hair is
cut, it is avoided that the missing scalp area affects the user's
visual perception, the display effect of the virtual hairstyle
model image is improved, and the user's trial experience is further improved.