Method and apparatus for training image recognition model, and image recognition method and apparatus
AssigneeTencent Technology (Shenzhen) Company Limited
InventorsHong Shang, Han Zheng, Zhongqian Sun
Life of this patent
Estimating the term…
Abstract
A method for training an image recognition model includes: obtaining training image sets; obtaining a first predicted probability, a second predicted probability, a third predicted probability, and a fourth predicted probability based on the training image sets by using an initial image recognition model; determining a target loss function according to the first predicted probability, the second predicted probability, the third predicted probability, and the fourth predicted probability; and training the initial image recognition model based on the target loss function, to obtain an image recognition model.
Claims20
A method for training an image recognition model, performed by an electronic device, the method comprising:
- obtaining training image sets, the training image sets comprising at least a first image set, a second image set, and a third image set, the first image set comprising at least one first image, the second image set comprising at least one second image and at least one perturbed image, the third image set comprising at least one third image, the first image being a labeled image corresponding to a first task, the second image being an unlabeled image corresponding to the first task, the third image being a labeled image corresponding to a second task, the first task and the second task being different tasks;
- obtaining a first predicted probability, a second predicted probability, a third predicted probability, and a fourth predicted probability based on the training image sets by using an initial image recognition model, the first predicted probability being a predicted result outputted based on the first image set, the second predicted probability and the third predicted probability being predicted results outputted based on the second image set, and the fourth predicted probability being a predicted result outputted based on the third image set;
- determining a target loss function according to the first predicted probability, the second predicted probability, the third predicted probability, and the fourth predicted probability, the target loss function comprising at least a first loss function determined according to the first predicted probability, a second loss function determined according to the second predicted probability and the third predicted probability, and a third loss function determined according to the fourth predicted probability;
- and
- training the initial image recognition model based on the target loss function, to obtain an image recognition model.
An electronic device, comprising:
- a memory, a transceiver, a processor, and a bus system,
- the memory being configured to store a program;
- the processor being configured to execute the program in the memory, to perform:
- obtaining training image sets, the training image sets comprising at least a first image set, a second image set, and a third image set, the first image set comprising at least one first image, the second image set comprising at least one second image and at least one perturbed image, the third image set comprising at least one third image, the first image being a labeled image corresponding to a first task, the second image being an unlabeled image corresponding to the first task, the third image being a labeled image corresponding to a second task, the first task and the second task being different tasks;
- obtaining a first predicted probability, a second predicted probability, a third predicted probability, and a fourth predicted probability based on the training image sets by using an initial image recognition model, the first predicted probability being a predicted result outputted based on the first image set, the second predicted probability and the third predicted probability being predicted results outputted based on the second image set, and the fourth predicted probability being a predicted result outputted based on the third image set;
- determining a target loss function according to the first predicted probability, the second predicted probability, the third predicted probability, and the fourth predicted probability, the target loss function comprising at least a first loss function determined according to the first predicted probability, a second loss function determined according to the second predicted probability and the third predicted probability, and a third loss function determined according to the fourth predicted probability;
- and
- training the initial image recognition model based on the target loss function, to obtain an image recognition model.
A non-transitory computer-readable storage medium, comprising instructions, the instructions, when run on a computer, causing the computer to perform:
- obtaining training image sets, the training image sets comprising at least a first image set, a second image set, and a third image set, the first image set comprising at least one first image, the second image set comprising at least one second image and at least one perturbed image, the third image set comprising at least one third image, the first image being a labeled image corresponding to a first task, the second image being an unlabeled image corresponding to the first task, the third image being a labeled image corresponding to a second task, the first task and the second task being different tasks;
- obtaining a first predicted probability, a second predicted probability, a third predicted probability, and a fourth predicted probability based on the training image sets by using an initial image recognition model, the first predicted probability being a predicted result outputted based on the first image set, the second predicted probability and the third predicted probability being predicted results outputted based on the second image set, and the fourth predicted probability being a predicted result outputted based on the third image set;
- determining a target loss function according to the first predicted probability, the second predicted probability, the third predicted probability, and the fourth predicted probability, the target loss function comprising at least a first loss function determined according to the first predicted probability, a second loss function determined according to the second predicted probability and the third predicted probability, and a third loss function determined according to the fourth predicted probability;
- and
- training the initial image recognition model based on the target loss function, to obtain an image recognition model.
Dependencies are inferred from the claim text.