The application provides a
visual media search method and an electronic device, and relates to the technical field of
image processing. After receiving a search statement input by a user, the electronic device determines a text
feature vector of the search statement. Then, the electronic device inputs the text
feature vector of the search statement and an image
feature vector of a
visual media stored locally by the electronic device into a text-
image matching model, so as to determine whether the search statement matches the
visual media by using the text-
image matching model, thereby realizing the search of the visual media. The text-
image matching model is trained by using positive and negative samples, the positive and negative samples are determined by distinguishing sample text elements corresponding to sample images, the sample text elements corresponding to the sample images include one text element in a text set corresponding to each
sample image, the text set corresponding to the sample images represents a set of description contents corresponding to the sample images, the training samples of the text-image matching model are determined quickly, and therefore the training efficiency of the text-image matching model can be improved.