Poetry generation method, device, electronic device and storage medium
Through the image recognition model, determine the target keywords in the image and select matching poems from the preset poetry collection, it solves the problem that users find it difficult to quickly match poems, realizes accurate matching and rapid acquisition of images and poems, and satisfies the display on social platforms. Mood needs.
Patent Information
- Application Number
- CN202010591279.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-24
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2040-06-24
AI Technical Summary
It is difficult for users to quickly and accurately match images with poems that match their themes on social platforms, especially for ordinary users, they need high literary support.
By obtaining the images to be processed, the target keywords of the target object in the image are determined using the pre-trained image recognition model, and the matching target poems are selected from the preset poetry collection, and the demand information such as poetry type, format and quantity are filtered.
It achieves accurate matching of images and poems, quickly obtains target poems, reduces the user's literary level requirements, and meets the user's needs to quickly display his mood.
Smart Images

Figure CN111797262B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of machine learning, and in particular to a poetry generation method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of social networks, displaying users' favorite images or images taken by users on social platforms and adding texts that match the theme of the displayed images to express the user's current mood has become one of the social methods that users are keen on. However, simply adding texts that match the theme of the image can no longer meet the needs of users. Poetry, as a literary art that explains the soul, is widely loved by people. In order to better show the mood that users want to express through images, when users display images on social platforms, they can add poems that match the theme of the displayed images. However, adding poems that match the theme of the displayed images requires a high level of literary proficiency of the users. For ordinary users, it is difficult to quickly and accurately add poems that match the theme of the displayed images. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a poetry generation method, device, electronic device and storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a method for generating poetry is provided, the method comprising:
[0005] Get the image to be processed input through the terminal;
[0006] According to the image to be processed, obtaining a target keyword corresponding to a target object in the image to be processed by a pre-trained image recognition model;
[0007] From a preset poetry set, determine the target poetry corresponding to the target keyword.
[0008] Optionally, obtaining a target keyword corresponding to a target object in the image to be processed by a pre-trained image recognition model according to the image to be processed includes:
[0009] Using the image to be processed as the input of the image recognition model, obtaining a keyword corresponding to each target object in the target object, and a confidence level corresponding to each keyword;
[0010] A preset number of keywords with the highest confidence among the keywords are used as the target keywords.
[0011] Optionally, determining a target poem corresponding to the target keyword from a preset poem set includes:
[0012] Determining a plurality of candidate poems corresponding to the target keyword from the preset poem set;
[0013] Determine the target poem from the multiple candidate poems.
[0014] Optionally, the preset poetry set includes a plurality of poems, and determining a plurality of candidate poems corresponding to the target keyword from the preset poetry set includes:
[0015] The poems that contain the target keyword among the multiple poems are used as the candidate poems.
[0016] Optionally, before determining the target poem corresponding to the target keyword from the preset poem set, the method further includes:
[0017] Acquire poetry demand information, wherein the poetry demand information includes at least one of a poetry type, a poetry format, and a poetry quantity;
[0018] Determining the target poem from the plurality of candidate poems comprises:
[0019] The candidate poem that matches the poem requirement information among the multiple candidate poems is used as the target poem.
[0020] Optionally, determining the target poem from the plurality of candidate poems comprises:
[0021] From the multiple candidate poems, the candidate poem selected by the user is used as the target poem.
[0022] Optionally, the method further comprises:
[0023] The image to be processed and the target poem are displayed.
[0024] Optionally, the image recognition model is trained in the following manner:
[0025] Acquire a sample training set, wherein the sample training set includes a training image and training keywords corresponding to the training image;
[0026] The preset training model is trained according to the sample training set to obtain the image recognition model.
[0027] Optionally, the training a preset training model according to the sample training set to obtain the image recognition model includes:
[0028] The training images and the training keywords are used as training samples to perform model training to obtain the image recognition model.
[0029] According to a second aspect of an embodiment of the present disclosure, a poetry generation device is provided, the device comprising:
[0030] An acquisition module is configured to acquire an image to be processed input through a terminal;
[0031] A recognition module is configured to obtain a target keyword corresponding to a target object in the image to be processed by a pre-trained image recognition model according to the image to be processed;
[0032] The determination module is configured to determine the target poem corresponding to the target keyword from a preset poem set.
[0033] Optionally, the identification module includes:
[0034] A first recognition submodule is configured to use the image to be processed as an input of the image recognition model to obtain a keyword corresponding to each target object in the target objects and a confidence level corresponding to each keyword;
[0035] The second identification submodule is configured to use a preset number of keywords with the highest confidence among the keywords as the target keywords.
[0036] Optionally, the determining module includes:
[0037] A first determination submodule is configured to determine a plurality of candidate poems corresponding to the target keyword from the preset poem set;
[0038] The second determination submodule is configured to determine the target poem from the multiple candidate poems.
[0039] Optionally, the preset poetry set includes multiple poems, and the first determination submodule is configured to select the poems containing the target keyword among the multiple poems as the candidate poems.
[0040] Optionally, the acquisition module is further configured to acquire poetry demand information before determining the target poetry corresponding to the target keyword from the preset poetry set, the poetry demand information including at least one of poetry type, poetry format and poetry quantity;
[0041] The second determination submodule is configured to select a candidate poem among the multiple candidate poems that matches the poem requirement information as the target poem.
[0042] Optionally, the second determination submodule is configured to select a candidate poem selected by the user as the target poem from among the multiple candidate poems.
[0043] Optionally, the device further comprises:
[0044] The display module is configured to display the image to be processed and the target poem.
[0045] Optionally, the image recognition model is trained in the following manner:
[0046] Acquire a sample training set, wherein the sample training set includes a training image and training keywords corresponding to the training image;
[0047] The preset training model is trained according to the sample training set to obtain the image recognition model.
[0048] Optionally, the training a preset training model according to the sample training set to obtain the image recognition model includes:
[0049] The training images and the training keywords are used as training samples to perform model training to obtain the image recognition model.
[0050] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0051] processor;
[0052] a memory for storing processor-executable instructions;
[0053] Among them, the processor is configured to execute the steps of the poetry generation method provided in the first aspect of the present disclosure.
[0054] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the poetry generation method provided in the first aspect of the present disclosure are implemented.
[0055] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: the present disclosure first obtains the image to be processed input through the terminal, and obtains the target keyword corresponding to the target object in the image to be processed through a pre-trained image recognition model according to the image to be processed, and finally determines the target poem corresponding to the target keyword from the preset poem set. The present disclosure determines the target poem by taking the target keyword corresponding to the target object in the image to be processed determined by the image recognition model as the theme of the image to be processed. The determined target poem can accurately match the theme of the image to be processed, and by using the target keyword to directly select the target poem from the preset poem set, the target poem can be quickly obtained.
[0056] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0058] Figure 1 The present invention is a flowchart of a method for generating poetry according to an exemplary embodiment.
[0059] Figure 2 yes Figure 1 The illustrated embodiment shows a flow chart of step 102 .
[0060] Figure 3 yes Figure 1 The illustrated embodiment shows a flow chart of step 103 .
[0061] Figure 4 It is a flowchart of another poetry generation method according to an exemplary embodiment.
[0062] Figure 5 It is a flowchart of another poetry generation method according to an exemplary embodiment.
[0063] Figure 6 The figure is a flowchart of a training image recognition model according to an exemplary embodiment.
[0064] Figure 7 It is a block diagram of a poetry generation device according to an exemplary embodiment.
[0065] Figure 8 yes Figure 7 The illustrated embodiment shows a block diagram of an identification module.
[0066] Fig. 9 yes Figure 7 The illustrated embodiment shows a block diagram of a determination module.
[0067] Fig.10 It is a block diagram of another poetry generation device according to an exemplary embodiment.
[0068] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0069] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0070] Before introducing the poetry generation method, device, electronic device and storage medium provided by the present disclosure, the application scenarios involved in each embodiment of the present disclosure are first introduced. The application scenario can be a scenario in which a user selects a target poem for an image to be processed through a terminal. The terminal can be, for example, a mobile terminal such as a smart phone, a tablet computer, a smart watch, a smart bracelet, a PDA (English: Personal Digital Assistant, Chinese: Personal Digital Assistant), or a fixed terminal such as a desktop computer.
[0071] Figure 1 FIG. 1 is a flow chart of a method for generating poetry according to an exemplary embodiment. Figure 1 As shown, the method may include the following steps.
[0072] In step 101, an image to be processed inputted through a terminal is obtained.
[0073] For example, when a user needs to add a poem that matches the theme of the image to be processed, the image to be processed can be input to the terminal, and the image to be processed can be further processed to obtain the poem that matches the theme of the image to be processed. The poem that matches the theme of the image to be processed can be obtained by the terminal or by the server, and the image to be processed can be an image taken by the user through the terminal or an image directly selected by the user from the local storage of the terminal.
[0074] In step 102, based on the image to be processed, a target keyword corresponding to the target object in the image to be processed is obtained through a pre-trained image recognition model.
[0075] In this step, the image to be processed can be input into a pre-trained image recognition model to obtain the target keywords corresponding to the target objects in the image to be processed output by the image recognition model. For example, when the image to be processed is a landscape image taken by a user through a mobile phone, and the target objects included in the landscape image are flowers, grass and trees, the target keywords corresponding to the target objects in the image to be processed can be obtained as "flowers", "grass" and "trees" through the image recognition model. Among them, the image recognition model can be, for example, a ResNet (English: Residual Network, Chinese: Residual Network) model, or a VGG (English: Visual Geometry Group Network) model, or any other model that can identify the target keywords corresponding to the target objects in the image to be processed, and the present disclosure does not make specific limitations on this.
[0076] In step 103, a target poem corresponding to the target keyword is determined from a preset poem set.
[0077] For example, after obtaining the target keyword, the target keyword can be used as the theme of the image to be processed, and based on the target keyword, a poem matching the target keyword can be selected from a plurality of poems included in a preset poem set. Then, according to the preset poem selection condition, the poems matching the target keyword are screened, and poems that meet the condition are selected as the target poems corresponding to the target keyword. For example, the poem selection condition can be to select poems that match the target keyword and have a seven-character regulated verse format as the target poem. In order to enable the determined target poem to accurately match the theme of the image to be processed, the poems included in the preset poem set can be high-quality poems selected after manual screening and investigation.
[0078] It should be noted that the determination of the target poem can be completed by the terminal or by the server terminal. When the determination of the target poem is completed by the terminal, the image recognition model and the preset poem set can be stored locally in the terminal. After the terminal obtains the image to be processed, it can directly input the image to be processed into the image recognition model, and determine the target poem from the preset poem set based on the target keyword output by the image recognition model. When the determination of the target poem is completed by the server, the image recognition model and the preset poem set can be stored on the server. After the terminal obtains the image to be processed, it can send the image to be processed to the server, and the server determines the target poem using the image recognition model and the preset poem set.
[0079] By adopting the above-mentioned scheme, the present invention determines the target poem by taking the target keyword corresponding to the target object in the image to be processed determined by the image recognition model as the theme of the image to be processed. The determined target poem can accurately match the theme of the image to be processed, and by using the target keyword to directly select the target poem from a preset poem set, the target poem can be quickly acquired.
[0080] Figure 2 yes Figure 1 The embodiment shown is a flow chart of step 102. Figure 2 As shown, step 102 may include the following steps:
[0081] In step 1021, the image to be processed is used as an input of the image recognition model to obtain keywords corresponding to each target object in the target object and the confidence level corresponding to each keyword.
[0082] For example, the method of determining the target keyword can be: first, based on the image to be processed, an image vector corresponding to the image to be processed can be generated, and the image vector is used as the input of the image recognition model to obtain the keyword corresponding to each target object in the target object output by the image recognition model, and the confidence corresponding to each keyword. For example, when the target objects included in the image to be processed are flowers, grass, trees and mountains, the image recognition model can be used to obtain the keywords corresponding to each target object in the image to be processed as "flowers", "grass", "trees" and "mountains", and the confidences corresponding to the keywords "flowers", "grass", "trees" and "mountains" are 0.1, 0.15, 0.35 and 0.4 respectively.
[0083] In step 1022, a preset number of keywords with the highest confidence among the keywords are used as target keywords.
[0084] For example, after determining the keywords corresponding to each target object and the confidence corresponding to each keyword, a preset number of keywords with the largest confidence among the keywords can be used as target keywords. For example, when the confidence corresponding to each keyword output by the image recognition model is 0.1, 0.15, 0.35, and 0.4, respectively, if the preset number is 2, the keywords with confidences of 0.35 and 0.4 are used as target keywords. Furthermore, keywords with confidences greater than or equal to a preset confidence threshold can also be used as target keywords. For example, when the confidences corresponding to each keyword output by the image recognition model are 0.1, 0.2, and 0.7, respectively, if the confidence threshold is 0.5, the keyword with a confidence of 0.7 is used as the target keyword.
[0085] Figure 3 yes Figure 1 The embodiment shown is a flow chart of step 103. Figure 3 As shown, step 103 may include the following steps:
[0086] In step 1031, multiple candidate poems corresponding to the target keyword are determined from a preset poem set.
[0087] For example, the method of determining the target poem can be: first, according to the target keyword, from the multiple poems included in the preset poem set, the poems containing the target keyword can be selected as candidate poems to obtain multiple candidate poems corresponding to the target keyword. In order to further improve the accuracy of the selected candidate poems, a mapping knowledge graph of the target keyword and the poem keyword can be established in advance (the poem keyword is a pre-set keyword corresponding to the poem theme). After determining the target keyword, the target poem keyword with the highest correlation with the target keyword can be determined according to the target keyword, and it can be determined whether there is a poem containing the target poem keyword among the multiple poems included in the preset poem set. If so, the poem containing the target poem keyword is selected as a candidate poem.
[0088] In another possible implementation, the target poem can also be determined by: pre-establishing a keyword tag for each of the multiple poems included in the preset poem set, the keyword tag including the poem keyword corresponding to the theme of the poem, and after determining the target keyword, the target keyword can be matched with the poem keyword included in the keyword tag, and when there is a poem keyword identical to the target keyword, the poem corresponding to the poem keyword is used as the target poem. For example, after collecting famous and classic poems from the Internet and establishing a preset poem set through manual screening and investigation, the poems in the preset poem set can be annotated, and the poem keywords contained in each poem can be marked and used as the keyword tag corresponding to the poem.
[0089] In step 1032, a target poem is determined from a plurality of candidate poems.
[0090] Furthermore, after determining the candidate poems, multiple candidate poems can be screened according to preset poem selection conditions, and poems that meet the conditions can be selected as target poems. The poem selection conditions can be preset or adjusted in real time according to the specific needs of the user. For example, the preset condition can be to select a poem of the ancient style from multiple candidate poems as the target poem.
[0091] Figure 4 FIG. 1 is a flow chart of another method for generating poetry according to an exemplary embodiment. Figure 4 As shown, before step 103, the method further includes the following steps:
[0092] In step 104, poetry demand information is obtained, and the poetry demand information includes at least one of the type of poetry, the format of poetry and the number of poetry.
[0093] In one scenario, before determining the target poem, the user can input poem requirement information to the terminal according to actual needs to adjust the poem selection conditions, thereby realizing the selection of the target poem. The poem requirement information includes at least one of the poem type, poem format and poem quantity (the poem quantity can be 3, for example), the poem type can include ancient poetry, modern poetry and regulated verse, and the poem format can include five-character quatrain, seven-character quatrain, five-character regulated verse and seven-character regulated verse.
[0094] Further, step 1032 can be implemented in the following manner:
[0095] The candidate poem that matches the poem requirement information among multiple candidate poems is taken as the target poem.
[0096] In one scenario, a poem label may be pre-established for each of the multiple poems included in the preset poem set, and the poem label may include the poem type and poem format corresponding to the poem. After determining multiple candidate poems, the poem demand information may be matched with the poem type and poem format included in the poem label to select candidate poems matching the poem demand information from the multiple candidate poems as target poems. For example, when the poem demand information includes the poem format and the number of poems, and the poem format included in the poem demand information is a five-character regulated verse, and the number of poems included in the poem demand information is 3, 3 candidate poems with a five-character regulated verse format may be selected from the multiple candidate poems as target poems.
[0097] Optionally, step 1032 may also be implemented in the following manner:
[0098] From multiple candidate poems, the candidate poem selected by the user is used as the target poem.
[0099] In another scenario, after determining multiple candidate poems, the multiple candidate poems can also be displayed to the user, and the user can select the candidate poems, and the candidate poems selected by the user are used as target poems. For example, the user can select the candidate poems through a specified APP (English: Application, Chinese: Application) installed on the terminal or by performing a specified operation on the display interface of the terminal (for example: long press operation, double click operation or zoom gesture operation in a specified area).
[0100] Figure 5 FIG. 1 is a flowchart of another method for generating poetry according to an exemplary embodiment. Figure 5 As shown, the method further comprises the following steps:
[0101] In step 105, the image to be processed and the target poem are displayed.
[0102] For example, after determining the target poem, the image to be processed and the target poem can be displayed on the display interface of the terminal. Furthermore, the user can input a target display instruction to the terminal so that the terminal displays the image to be processed and the target poem according to the target display instruction, wherein the target display instruction may include the relative position of the target poem and the image to be processed (for example, the target poem can be located above the image to be processed), the font type of the target poem (the font type can be, for example, Songti, Bold, Kaiti, and Lishu, etc.) and the text color of the target poem, etc.
[0103] Figure 6 FIG. 1 is a flowchart of an image recognition model according to an exemplary embodiment. Figure 6 As shown, the image recognition model can be trained in the following ways:
[0104] In step 201, a sample training set is obtained, where the sample training set includes training images and training keywords corresponding to the training images.
[0105] For example, the method of training the image recognition model may be: first, a sample training set may be obtained, the sample training set may include a training image, and a training keyword corresponding to the training image, wherein the training keyword may be a keyword obtained by pre-labeling the target object in the training image. For example, when the training image is an image including the moon, the training keyword corresponding to the training image may be set to "moon".
[0106] In step 202, a preset training model is trained according to a sample training set to obtain an image recognition model.
[0107] For example, after obtaining the sample training set, the training images and training keywords can be used as training samples for model training to obtain an image recognition model. In order to ensure that the image recognition model can accurately identify the target keywords of the image to be processed, the trained image recognition model can also be tested. For example, a test set consisting of test images and test keywords corresponding to the test images can be obtained, and then the image recognition model is tested in turn using each group of test images and test keywords. If the accuracy of the target keywords output by the image recognition model is greater than or equal to the preset accuracy threshold, it is determined that the accuracy of keyword recognition of the image recognition model meets the requirements. Otherwise, it is determined that the accuracy of keyword recognition of the image recognition model does not meet the requirements, and the image recognition model needs to be retrained.
[0108] In summary, the present invention determines the target poem by taking the target keyword corresponding to the target object in the image to be processed determined by the image recognition model as the theme of the image to be processed. The determined target poem can accurately match the theme of the image to be processed, and by using the target keyword to directly select the target poem from a preset poem set, the target poem can be quickly acquired.
[0109] Figure 7 is a block diagram of a poetry generation device according to an exemplary embodiment. Figure 7 As shown, the device 300 includes an acquisition module 301 , an identification module 302 and a determination module 303 .
[0110] The acquisition module 301 is configured to acquire the image to be processed input through the terminal.
[0111] The recognition module 302 is configured to obtain target keywords corresponding to the target object in the image to be processed through a pre-trained image recognition model according to the image to be processed.
[0112] The determination module 303 is configured to determine the target poem corresponding to the target keyword from a preset poem set.
[0113] Figure 8 yes Figure 7 The embodiment shown is a block diagram of an identification module. Figure 8 As shown, the identification module 302 includes:
[0114] The first recognition submodule 3021 is configured to use the image to be processed as an input of the image recognition model to obtain a keyword corresponding to each target object in the target object and a confidence level corresponding to each keyword.
[0115] The second identification submodule 3022 is configured to use a preset number of keywords with the highest confidence among the keywords as target keywords.
[0116] Fig. 9 yes Figure 7 The embodiment shown is a block diagram of a determination module. Fig. 9 As shown, the determination module 303 includes:
[0117] The first determination submodule 3031 is configured to determine a plurality of candidate poems corresponding to the target keyword from a preset poem set.
[0118] The second determination submodule 3032 is configured to determine a target poem from a plurality of candidate poems.
[0119] Optionally, the preset poetry set includes multiple poems, and the first determination submodule 3031 is configured to select poems containing the target keyword among the multiple poems as candidate poems.
[0120] Optionally, the acquisition module 301 is also configured to acquire poetry demand information before determining the target poetry corresponding to the target keyword from a preset poetry set, and the poetry demand information includes at least one of the poetry type, poetry format and poetry quantity.
[0121] The second determination submodule 3032 is configured to select a candidate poem that matches the poem requirement information among multiple candidate poems as a target poem.
[0122] Optionally, the second determination submodule 3032 is configured to select a candidate poem selected by the user as a target poem from a plurality of candidate poems.
[0123] Fig.10 FIG. 1 is a block diagram of another poetry generation device according to an exemplary embodiment. Fig.10 As shown, the device 300 also includes: a display module 304.
[0124] The display module 304 is configured to display the image to be processed and the target poem.
[0125] Optionally, the image recognition model is trained by:
[0126] A sample training set is obtained, where the sample training set includes training images and training keywords corresponding to the training images.
[0127] The preset training model is trained according to the sample training set to obtain an image recognition model.
[0128] Optionally, training a preset training model according to a sample training set to obtain an image recognition model includes:
[0129] The training images and training keywords are used as training samples to train the model and obtain an image recognition model.
[0130] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0131] In summary, the present invention determines the target poem by taking the target keyword corresponding to the target object in the image to be processed determined by the image recognition model as the theme of the image to be processed. The determined target poem can accurately match the theme of the image to be processed, and by using the target keyword to directly select the target poem from a preset poem set, the target poem can be quickly acquired.
[0132] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the steps of the poetry generation method provided by the present disclosure.
[0133] In summary, the present invention determines the target poem by taking the target keyword corresponding to the target object in the image to be processed determined by the image recognition model as the theme of the image to be processed. The determined target poem can accurately match the theme of the image to be processed, and by using the target keyword to directly select the target poem from a preset poem set, the target poem can be quickly acquired.
[0134] Fig.11 8 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0135] Reference Fig.11 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0136] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned poetry generation method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0137] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0138] The power component 806 provides power to the various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
[0139] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0140] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0141] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0142] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0143] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0144] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned poetry generation method.
[0145] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to complete the above-mentioned poetry generation method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0146] In another exemplary embodiment, a computer program product is also provided, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned poetry generation method when executed by the programmable device.
[0147] In summary, the present invention determines the target poem by taking the target keyword corresponding to the target object in the image to be processed determined by the image recognition model as the theme of the image to be processed. The determined target poem can accurately match the theme of the image to be processed, and by using the target keyword to directly select the target poem from a preset poem set, the target poem can be quickly acquired.
[0148] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0149] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A poetry generation method, characterized in that: The method comprises: Get the image to be processed input through the terminal; According to the image to be processed, obtaining a target keyword corresponding to a target object in the image to be processed by a pre-trained image recognition model; Determine a target poem corresponding to the target keyword from a preset poem set; The step of obtaining a target keyword corresponding to a target object in the image to be processed by a pre-trained image recognition model according to the image to be processed includes: Using the image to be processed as the input of the image recognition model, obtaining a keyword corresponding to each target object in the target object, and a confidence level corresponding to each keyword; Using a preset number of keywords with the highest confidence among the keywords as the target keywords; Preliminarily establishing a keyword tag for each of the plurality of poems included in the preset poem set, wherein the keyword tag includes a poem keyword corresponding to a theme of the poem; After determining the target keyword, the target keyword is matched with the poetry keyword included in the keyword tag. When there is a poetry keyword that is the same as the target keyword, the poem corresponding to the poetry keyword is used as the target poem.
2. The method according to claim 1, characterized in that Determining the target poem corresponding to the target keyword from the preset poem set includes: Determining a plurality of candidate poems corresponding to the target keyword from the preset poem set; Determine the target poem from the multiple candidate poems.
3. The method according to claim 2, characterized in that The preset poetry set includes a plurality of poems, and the step of determining a plurality of candidate poems corresponding to the target keyword from the preset poetry set includes: The poems that contain the target keyword among the multiple poems are used as the candidate poems.
4. The method according to claim 2, characterized in that: Before determining the target poem corresponding to the target keyword from the preset poem set, the method further includes: Acquire poetry demand information, wherein the poetry demand information includes at least one of a poetry type, a poetry format, and a poetry quantity; Determining the target poem from the plurality of candidate poems comprises: The candidate poem that matches the poem requirement information among the multiple candidate poems is used as the target poem.
5. The method according to claim 2, characterized in that: Determining the target poem from the plurality of candidate poems comprises: From the multiple candidate poems, the candidate poem selected by the user is used as the target poem.
6. The method according to claim 1, characterized in that The method further comprises: The image to be processed and the target poem are displayed.
7. The method according to any one of claims 1 to 6, characterized in that The image recognition model is trained in the following way: Acquire a sample training set, wherein the sample training set includes a training image and training keywords corresponding to the training image; The preset training model is trained according to the sample training set to obtain the image recognition model.
8. The method according to claim 7, characterized in that The training of the preset training model according to the sample training set to obtain the image recognition model comprises: The training images and the training keywords are used as training samples to perform model training to obtain the image recognition model.
9. A poetry generation device, characterized in that: The device comprises: An acquisition module is configured to acquire an image to be processed input through a terminal; A recognition module is configured to obtain a target keyword corresponding to a target object in the image to be processed by a pre-trained image recognition model according to the image to be processed; A determination module is configured to determine a target poem corresponding to the target keyword from a preset poem set; The identification module comprises: A first recognition submodule is configured to use the image to be processed as an input of the image recognition model to obtain a keyword corresponding to each target object in the target objects and a confidence level corresponding to each keyword; A second identification submodule is configured to select a preset number of keywords with the highest confidence among the keywords as the target keywords; The device also includes: A preset module is configured to pre-establish a keyword tag for each of the multiple poems included in the preset poem set, wherein the keyword tag includes a poem keyword corresponding to a theme of the poem; The second determination module is configured to match the target keyword with the poetry keyword included in the keyword tag after determining the target keyword. When there is a poetry keyword that is the same as the target keyword, the poem corresponding to the poetry keyword is used as the target poem.
10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.
