✨ A simple plug-in based on AI model~ ✨
This plug-in is for entertainment and learning communication only.
NaiLongRemove is a NaiLong recognition plug-in built with a simple AI model, which can identify NaiLong emoticons in the group and withdraw the emoticons.
Currently, the plug-in supports two models, which can be changed through configuration files. For details, see the configuration section at the bottom of the document.
Users can choose their favorite model according to their needs. The performance of both models has been optimized, but there may still be varying degrees of error. You are also welcome to continue to give us feedback~
If you have never worked with NoneBot, please check out this documentation
Just choose any one of the methods mentioned below
nb plugin install nonebot-plugin-nailongremove
pip install nonebot-plugin-nailongremove
pdm add nonebot-plugin-nailongremove
poetry add nonebot-plugin-nailongremove
conda install nonebot-plugin-nailongremove
Open the pyproject.toml
file in the root directory of the nonebot2 project, and add it to the plugins
item in the [tool.nonebot]
section.
[tool.nonebot]plugins = [ # ... "nonebot_plugin_nailongremove"]
Add the required configuration in the following table to the .env
file of the nonebot2 project
Configuration items | Required | default value | illustrate |
---|---|---|---|
Global configuration | |||
PROXY | no | None | The proxy address used when downloading files such as models |
Response configuration | |||
NAILONG_BYPASS_SUPERUSER | no | True | Whether to not check images sent by superusers |
NAILONG_BYPASS_ADMIN | no | True | Whether to not check images sent by group administrators |
NAILONG_NEED_ADMIN | no | False | Whether to not check all pictures in the group when you are not the group administrator |
NAILONG_LIST_SCENES | no | [] | The chat scene ID black and white list is the chat ID under single-level chat, such as QQ group number; Under multi-level chat, it is the chat ID of each level separated by _ , such as a sub-channel under a channel or a private chat under a channel |
NAILONG_BLACKLIST | no | True | Whether to use blacklist mode |
NAILONG_PRIORITY | no | 100 | Matcher priority |
behavior configuration | |||
NAILONG_RECALL | no | True | Whether to withdraw the message |
NAILONG_MUTE_SECONDS | no | 0 | Set the muting time, the default is 0, that is, no muting unit: seconds |
NAILONG_TIP | no | 本群禁止发奶龙! | To send a prompt, use Alconna’s message template. The available variables are shown below. |
NAILONG_FAILED_TIP | no | {:Reply($message_id)}呜,不要发奶龙了嘛? ?? | Prompt sent when recall fails or is disabled, same as above |
Model general configuration | |||
NAILONG_MODEL_DIR | no | ./data/nailongremove | Download location of the model |
NAILONG_MODEL | no | 0 | Select the model to be loaded. The available models are shown below. |
NAILONG_AUTO_UPDATE_MODEL | no | True | Whether to automatically update the model |
NAILONG_CONCURRENCY | no | 1 | When the picture is a moving picture, the maximum number of concurrently recognized picture frames for the picture |
NAILONG_ONNX_TRY_TO_USE_GPU | no | True | Whether to try to use the GPU when loading the onnx model. If it fails, a series of warnings will be displayed but will have no impact on the plug-in. If you do not want to see warnings, just close this configuration item. |
Model 1 specific configuration | |||
NAILONG_MODEL1_YOLOX_SIZE | no | [416,416] | For model 1, custom model inputs may have size changes |
NAILONG_MODEL1_TYPE | no | tiny | Model 1 The model type used, available tiny / m |
NAILONG_MODEL1_SCORE | no | 0.5 | Model 1 confidence threshold, range 0 ~ 1 |
Miscellaneous configuration | |||
NAILONG_GITHUB_TOKEN | no | None | GitHub Access Token, you can try to fill it in if you encounter problems downloading or updating the model. |
0
: Inference based on Renet50 image classification model training, thanks to @spawner1145 for providing the model, original link: spawner1145/NailongRecognize
1
: Training inference based on YOLOX target detection model, thanks to @NKXingXh for providing the model, original link: nkxingxh/NailongDetection
variable name | type | illustrate |
---|---|---|
$event | Event | current events |
$target | Target | event target |
$message_id | str | Message ID |
$msg | UniMessage | current news |
$ss | Session | current session |
$checked_image | bytes | The picture after the corresponding target is selected in the frame, only exists when the model configuration is 1 |
As soon as someone recognizes the Milk Dragon emoticon, it will be withdrawn and reminded.
Nonebot2 official communication group: 768887710 (basic installation and deployment questions can be asked here)
Artificial Intelligence Learning and Exchange Group: 949992679 (You can come here to learn and exchange AI related technologies)
Robot plug-in learning exchange group: 200980266 (Feedback on robot BUG model accuracy and other issues can be found here)
Welcome everyone to join the group to learn and communicate together~
Optimization model automatically updated (possibly reverse optimization)
Rename the configuration item NAILONG_YOLOX_SIZE
-> NAILONG_MODEL1_YOLOX_SIZE
Model 1 can now automatically obtain the latest version, or you can select the model type to use through configuration
Model 1 can now control the recognition confidence threshold through configuration items
When loading the onnx model, it will try to use the GPU by default. If it fails, a series of warnings will be displayed. If you don't want to see the warnings, refer to the above to turn off the corresponding configuration.
Fix the bug that NAILONG_NEED_ADMIN
configuration does not take effect
Fixed the bug of ignoring group management and super user being invalid
Refactor some code and fix potential bugs
Added variable $checked_image
Download the model from the original repository
Refactor the plug-in to adapt to multiple platforms
Two new models have been updated to optimize model accuracy. Users can choose one of them for inference.
Added functions such as banning, group black and white list, optionally turning off administrator detection, etc.
Added automatic update model option