API:https://smilingwolf-wd-tagger.hf.space
入参:[file, ‘SmilingWolf/wd-swinv2-tagger-v3’, 0.35, false, 0.85, false,]
最好能用户在QQ里引用图片,或者表情,然后用这个API得到返回的图片反推信息,并将其返回。
看了下,是这个原理,发送了3个请求:
上传图片
https://smilingwolf-wd-tagger.hf.space/upload?upload_id={hash}
进行分析
https://smilingwolf-wd-tagger.hf.space/queue/join
查看结果
https://smilingwolf-wd-tagger.hf.space/queue/data?session_hash={hash}
完成一套,需要进行3个操作。
- 上传图片需要发送 formata 数据,files 需要插入二进制图片,返回相对路径
- 分析图片需要获得该图片的相对路径,和会话的哈希值标识
- 查看结果直接在 query 参数插入 哈希值标识,得到结果
上传图片
分析图片
查看结果
谢谢!
感谢,非常好用。提一个小需求,群里的人一起用时可能会出现未知错误,能否将队列加上?
我没能复现这个问题,多个请求同时发起也不会出现错误,能给一下报错的日志吗
{“id”:8256,“type”:“warn”,“level”:2,“name”:“command”,“meta”:{},“content”:“tagger \nError: Not Found\n at [cordis.invoke] (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\plugin-http\node_modules\@cordisjs\plugin-http\lib\index.cjs:332:23)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Proxy. (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\plugin-http\node_modules\@cordisjs\plugin-http\lib\index.cjs:185:26)\n at async Command. (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\koishi-plugin-waifu-diffusion-tagger\lib\index.js:73:40)\n at async Array. (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:1121:14)\n at async Command.execute (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:1135:22)\n at async C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:2154:22\n at async Proxy.withScope (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:2057:22)\n at async next (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:860:16)\n at async next (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:860:16)”,“timestamp”:1716888743116}
{“id”:8273,“type”:“warn”,“level”:2,“name”:“command”,“meta”:{},“content”:“tagger <img src="https://gchat.qpic.cn/download?appid=1407&fileid=CgozNDM0NTk1NDY1EhSp5onpPrcLWBVv9_ufKuf_ejggURiH4wEg_woo6ce94YSwhgNQgL2jAQ&rkey=CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64&spec=0\” file="0F714928AA99BDF1A3BCB4BD89A0357C.jpg" url="https://gchat.qpic.cn/download?appid=1407&fileid=CgozNDM0NTk1NDY1EhSp5onpPrcLWBVv9_ufKuf_ejggURiH4wEg_woo6ce94YSwhgNQgL2jAQ&rkey=CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64&spec=0\" file-size="29063"/>\nError: Not Found\n at [cordis.invoke] (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\plugin-http\node_modules\@cordisjs\plugin-http\lib\index.cjs:332:23)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Proxy. (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\plugin-http\node_modules\@cordisjs\plugin-http\lib\index.cjs:185:26)\n at async Command. (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\koishi-plugin-waifu-diffusion-tagger\lib\index.js:73:40)\n at async Array. (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:1121:14)\n at async Command.execute (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:1135:22)\n at async C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:2154:22\n at async Proxy.withScope (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:2057:22)\n at async next (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:860:16)\n at async next (C:\Users\Administrator\AppData\Roaming\Koishi\Desktop\data\instances\mytag\node_modules\@koishijs\core\lib\index.cjs:860:16)",“timestamp”:1716888868408}
偶尔会出现这个Not Found ,多发几次会成功。然后有的图片一直会提示:“未知错误”,近期我一直在用你的插件,我今晚也收集一点日志发出来。
有没有可能是同时访问api太多的问题?能不能一次性多填入几个api轮流随机使用?
看了下日志,日志里那个链接的确访问不到图片,那个地址是QQ的么,或者不用QQ获取的链接?让图片先下载到服务器本地?然后在进行上传反推?很奇怪,大部分能直接用这个QQ的地址访问,而某些图片QQ产生的这个地址无法访问到图片。
这可能还是适配器的问题,因为插件只能通过适配器提供的资源地址访问资源,这个资源无法访问的话确实没有办法
这跟api应该没什么关系,因为这个图片资源的地址就无法访问,也没有其他api可以用了(?)
PC端发图片基本没问题 出问题的都是手机发的