Demo
# Demo
# 示例
import asyncio
from loguru import logger
from PicImageSearch import Iqdb, Network
from PicImageSearch.model import IqdbResponse
# proxies = "http://127.0.0.1:1081"
proxies = None
# url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test01.jpg"
url = r"images/test01.jpg" # 搜索本地图片
@logger.catch()
async def test() -> None:
async with Network(proxies=proxies) as client:
iqdb = Iqdb(client=client)
resp = await iqdb.search(url)
# resp = await iqdb.search(url, is_3d=True)
show_result(resp)
def show_result(resp: IqdbResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.raw[0].origin)
logger.info("说明: " + resp.raw[0].content)
logger.info("来源地址: " + resp.raw[0].url)
logger.info("缩略图: " + resp.raw[0].thumbnail)
logger.info("相似度: " + str(resp.raw[0].similarity))
logger.info("图片大小: " + resp.raw[0].size)
logger.info("图片来源: " + resp.raw[0].source)
logger.info("其他图片来源: " + str(resp.raw[0].other_source))
logger.info("SauceNAO搜图链接: " + resp.saucenao_url)
logger.info("Ascii2d搜图链接: " + resp.ascii2d_url)
logger.info("TinEye搜图链接: " + resp.tineye_url)
logger.info("Google搜图链接: " + resp.google_url)
logger.info("相似度低的结果有多少: " + str(len(resp.more)))
logger.info("-" * 50)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(test())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from loguru import logger
from PicImageSearch.model import IqdbResponse
from PicImageSearch.sync import Iqdb as IqdbSync
# proxies = "http://127.0.0.1:1081"
proxies = None
# url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test01.jpg"
url = r"images/test01.jpg" # 搜索本地图片
@logger.catch()
def test_sync() -> None:
iqdb = IqdbSync(proxies=proxies)
resp = iqdb.search(url)
# resp = iqdb.search(url, is_3d=True)
show_result(resp)
def show_result(resp: IqdbResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.raw[0].origin)
logger.info("说明: " + resp.raw[0].content)
logger.info("来源地址: " + resp.raw[0].url)
logger.info("缩略图: " + resp.raw[0].thumbnail)
logger.info("相似度: " + str(resp.raw[0].similarity))
logger.info("图片大小: " + resp.raw[0].size)
logger.info("图片来源: " + resp.raw[0].source)
logger.info("其他图片来源: " + str(resp.raw[0].other_source))
logger.info("SauceNAO搜图链接: " + resp.saucenao_url)
logger.info("Ascii2d搜图链接: " + resp.ascii2d_url)
logger.info("TinEye搜图链接: " + resp.tineye_url)
logger.info("Google搜图链接: " + resp.google_url)
logger.info("相似度低的结果有多少: " + str(len(resp.more)))
logger.info("-" * 50)
if __name__ == "__main__":
# test_sync()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Make sure to add code blocks to your code group
- name: 前往查看
desc: 🚀异步测试文件Demo
link: https://github.com/kitUIN/PicImageSearch/blob/main/demo/demo_iqdb_3d.py
bgColor: '#DFEEE7'
textColor: '#2A3344'
1
2
3
4
5
6
7
2
3
4
5
6
7
程序输出,部分过长数据已省略
2022-03-27 19:55:03.164 | INFO | __main__:show_result:35 - <table><tr><th>Best match</th></tr><tr><td class="image"><a href="//danbooru.donmai.us/posts/4885675"><img src="/danbooru/6/e/0/6e0d18b51c232dc81b29f0c092c246e5.jpg" alt="Rating: s Score: 7 Tags: 1boy 1girl absurdres babydoll black_hair bloomers breasts chemise cleavage covered_face cowboy_shot dress formal grey_background halloween_costume hat hat_ribbon hetero highres holding_necktie idolmaster idolmaster_shiny_colors implied_kiss kazano_hiori navel producer_(idolmaster) ribbon shirt simple_background smile sweatdrop syhan underwear white_dress white_shirt witch_hat" title="Rating: s Score: 7 Tags: 1boy 1girl absurdres babydoll black_hair bloomers breasts chemise cleavage covered_face cowboy_shot dress formal grey_background halloween_costume hat hat_ribbon hetero highres holding_necktie idolmaster idolmaster_shiny_colors implied_kiss kazano_hiori navel producer_(idolmaster) ribbon shirt simple_background smile sweatdrop syhan underwear white_dress white_shirt witch_hat"/></a></td></tr><tr><td><img alt="icon" src="/icon/danbooru.ico" class="service-icon"/>Danbooru <span class="el"><a href="//gelbooru.com/index.php?page=post&s=list&md5=6e0d18b51c232dc81b29f0c092c246e5"><img alt="icon" src="/icon/gelbooru.png" class="service-icon"/>Gelbooru</a></span></td></tr><tr><td>2504×3180 [Safe]</td></tr><tr><td>91% similarity</td></tr></table>
2022-03-27 19:55:03.164 | INFO | __main__:show_result:36 - 说明: Best match
2022-03-27 19:55:03.164 | INFO | __main__:show_result:37 - 来源地址: https://danbooru.donmai.us/posts/4885675
2022-03-27 19:55:03.164 | INFO | __main__:show_result:38 - 缩略图: https://iqdb.org/danbooru/6/e/0/6e0d18b51c232dc81b29f0c092c246e5.jpg
2022-03-27 19:55:03.165 | INFO | __main__:show_result:39 - 相似度: 91.0
2022-03-27 19:55:03.165 | INFO | __main__:show_result:40 - 图片大小: 2504×3180 [Safe]
2022-03-27 19:55:03.165 | INFO | __main__:show_result:41 - 图片来源: Danbooru
2022-03-27 19:55:03.165 | INFO | __main__:show_result:42 - 其他图片来源: []
2022-03-27 19:55:03.165 | INFO | __main__:show_result:43 - SauceNAO搜图链接: https://saucenao.com/search.php?db=999&dbmaski=32768&url=https://iqdb.org/thu/thu_64cbe97f.jpg
2022-03-27 19:55:03.165 | INFO | __main__:show_result:44 - Ascii2d搜图链接: https://ascii2d.net/search/url/https://iqdb.org/thu/thu_64cbe97f.jpg
2022-03-27 19:55:03.165 | INFO | __main__:show_result:45 - TinEye搜图链接: https://tineye.com/search?url=https://iqdb.org/thu/thu_64cbe97f.jpg
2022-03-27 19:55:03.165 | INFO | __main__:show_result:46 - Google搜图链接: https://www.google.com/searchbyimage?image_url=https://iqdb.org/thu/thu_64cbe97f.jpg&safe=off
2022-03-27 19:55:03.165 | INFO | __main__:show_result:47 - 相似度低的结果有多少: 12
2022-03-27 19:55:03.165 | INFO | __main__:show_result:48 - --------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
上次更新: 2022/03/27, 20:47:51