{"id":239,"date":"2023-03-26T23:48:11","date_gmt":"2023-03-26T15:48:11","guid":{"rendered":"https:\/\/andy9999678.me\/blog\/?p=239"},"modified":"2023-05-03T03:35:56","modified_gmt":"2023-05-02T19:35:56","slug":"%e4%bd%bf%e7%94%a8-clip-%e6%a8%a1%e5%9e%8b%e6%90%ad%e5%bb%ba%e7%ae%80%e6%98%93%e7%9a%84%e4%b8%aa%e4%ba%ba%e5%9b%be%e5%83%8f%e6%90%9c%e7%b4%a2%e5%bc%95%e6%93%8e","status":"publish","type":"post","link":"https:\/\/andy9999678.me\/blog\/archives\/239","title":{"rendered":"\u57fa\u4e8e CLIP \u6a21\u578b\u7279\u5f81\u642d\u5efa\u7b80\u6613\u7684\u4e2a\u4eba\u56fe\u50cf\u641c\u7d22\u5f15\u64ce"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Update: \u5df2\u7ecf\u66f4\u65b0 Github \u4ee3\u7801: <a href=\"https:\/\/github.com\/atarss\/clip-image-search\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/atarss\/clip-image-search<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u5468\u82b1\u4e86\u4e00\u5468\u65f6\u95f4\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7b80\u6613\u7684\u4e2a\u4eba\u56fe\u50cf\u641c\u7d22\u5f15\u64ce\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4ee5\u56fe\u641c\u56fe\u548c\u7528\u6587\u5b57\u641c\u56fe\u7684\u529f\u80fd\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/1.full_-1024x541.webp\" alt=\"\" class=\"wp-image-242\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/1.full_-1024x541.webp 1024w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/1.full_-300x159.webp 300w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/1.full_-768x406.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/1.full_-1536x812.webp 1536w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/1.full_-2048x1083.webp 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\u5c1d\u8bd5\u56fe\u641c\u56fe\u7684\u6548\u679c\u5c24\u5176\u597d\uff0c\u8fdc\u8d85\u51fa\u4e86\u6211\u7684\u9884\u671f\u3002\u6211\u4e4b\u524d\u7528\u7684 iPhone \u76f8\u518c\u548c Google Photos \u81ea\u5e26\u7684\u641c\u7d22\u5df2\u7ecf\u88ab\u8fd9\u4e2a\u7ed3\u679c\u540a\u6253\u4e86\u3002\u770b\u5230\u8fd9\u4e2a\u6548\u679c\u6211\u628a\u6211\u4e4b\u524d QQ \u7fa4\u804a\u5929\u8bb0\u5f55\u7684\u63a5\u8fd1\u767e\u4e07\u91cf\u7ea7\u7684\u56fe\u7247\u90fd\u8dd1\u4e86\u4e00\u904d CLIP Feature\uff0c\u7b80\u5355\u642d\u4e86\u4e00\u4e2a\u4e2a\u4eba\u56fe\u7247\u641c\u7d22\u5f15\u64ce\u3002\u8fd9\u91cc\u628a\u8fc7\u7a0b\u8bb0\u5f55\u4e0b\u6765\u5206\u4eab\u7ed9\u5927\u5bb6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u80cc\u666f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u5f00\u59cb\u662f\u5e74\u521d\u88ab\u540c\u4e8b\u5b89\u5229\u4e86\u4e00\u4e2a iOS \u7684 app \u53eb <a rel=\"noreferrer noopener\" href=\"https:\/\/apps.apple.com\/jp\/app\/queryable-find-photo-by-text\/id1661598353\" target=\"_blank\">Queryable<\/a>\uff08\u5bfb\u9690\uff09\uff0c\u53ef\u4ee5\u7528\u6587\u5b57\u641c\u56fe\u597d\u50cf\u6548\u679c\u8fd8\u4e0d\u9519\u3002\u60f3\u5230\u81ea\u5df1\u786e\u5b9e\u4e4b\u524d\u4e5f\u9047\u5230\u8fc7\u6709\u51e0\u5f20\u56fe\u6211\u60f3\u7ed9\u522b\u4eba\u770b\uff0c\u4f46\u81ea\u5e26\u7684\u641c\u7d22\u529f\u80fd\u5b8c\u5168\u6ca1\u6cd5\u5feb\u901f\u627e\u5230\uff0c\u6700\u540e\u627e\u534a\u5929\u4e5f\u627e\u4e0d\u7740\u53ea\u80fd\u4f5c\u7f62\u3002\u4e4b\u524d\u542c\u8bf4\u8fd9\u4e2a\u6b63\u662f\u7528 CLIP Feature \u5b9e\u73b0\u7684\u3002\u4e0a\u5468\u6b63\u597d\u6709\u65f6\u95f4\uff0c\u60f3\u8bd5\u4e0b\u73b0\u5728\u8fd9\u4e2a CLIP \u5230\u5e95\u6709\u591a\u597d\u7528\uff0c\u5c31\u505a\u4e86\u4e2a\u7b80\u5355\u7684\u5b9e\u9a8c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"503\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223107-1024x503.webp\" alt=\"\" class=\"wp-image-243\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223107-1024x503.webp 1024w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223107-300x147.webp 300w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223107-768x377.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223107-jpg.webp 1245w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u5f20\u90fd\u662f\u6211\u81ea\u5df1\u62cd\u5230\u7684\u6c7d\u8f66\u7684\u7167\u7247\uff0c\u4e24\u6b21\u90fd\u9047\u5230\u4e86\u201c\u6211\u60f3\u7ed9\u4eba\u770b\u6211\u4e4b\u524d\u5728\u8def\u8fb9\u89c1\u8fc7\u5f88\u6709\u8da3\u7684\u8f66\u201d\uff0c\u4e4b\u524d\u7528 iPhone \u81ea\u5e26\u7684\u641c\u7d22\u53ea\u80fd\u7528 &#8216;Car&#8217; \u5173\u952e\u8bcd\uff0c\u641c\u51fa\u6765\u4e00\u5927\u5806\u5e72\u6270\u9879\uff0c\u60f3\u5f3a\u8c03\u6c7d\u8f66\u7684\u989c\u8272\u548c\u54c1\u724c\u662f\u5b8c\u5168\u4e0d\u73b0\u5b9e\u7684\uff0c\u800c\u8fd9\u91cc\u7528\u66f4\u52a0\u8be6\u7ec6\u7684\u63cf\u8ff0\uff08\u84dd\u8272\u7684 Subaru \/ \u7c89\u8272\u7684\u4fdd\u65f6\u6377\uff09\u76f4\u63a5\u5c31\u53ef\u4ee5\u5feb\u901f\u641c\u7d22\u5230\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"489\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223438-1024x489.webp\" alt=\"\" class=\"wp-image-244\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223438-1024x489.webp 1024w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223438-300x143.webp 300w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223438-768x367.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326223438-jpg.webp 1102w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4ec0\u4e48 CLIP \u8fd9\u4e48\u597d\u7528\uff0c\u56e0\u4e3a CLIP \u5728\u8bad\u7ec3\u7684\u65f6\u5019\u4f1a\u540c\u65f6\u76d1\u7763\u56fe\u50cf\u4e0e\u6587\u672c\u6807\u7b7e\u7684\u5185\u5bb9\uff0c\u4f7f\u5f97\u4e0d\u7ba1\u6587\u5b57\u548c\u56fe\u50cf\u90fd\u4f1a\u88ab\u7f16\u7801\u5230\u540c\u4e00\u4e2a\u7a7a\u95f4\u4e0a\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u540c\u4e00\u4e2a\u7a7a\u95f4\u4e0a\u5ea6\u91cf\u56fe\u50cf\u7279\u5f81\u548c\u6587\u672c\u7279\u5f81\u3002\u5f53\u7136\u8fd9\u4e2a\u53ea\u662f\u6240\u8c13\u7406\u8bba\uff0c\u5177\u4f53\u8fd8\u5f97\u770b\u5b9e\u9645\u6548\u679c\uff0c\u540e\u9762\u4f1a\u6709\u6211\u81ea\u5df1\u56fe\u5e93\u4e0a\u7684\u641c\u7d22\u5c55\u793a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bbe\u8ba1\u601d\u8def\u4e0e\u5b9e\u73b0<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u56fe\u50cf\u6765\u6e90\uff1aiPhone \u53ef\u4ee5\u76f4\u63a5\u7528 iTunes \u5bfc\u5165\u624b\u673a\u76f8\u518c\u7684\u539f\u59cb\u56fe\u7247\u5230\u7535\u8111\u91cc\u9762\u3002Google Photo \u53ef\u4ee5\u7528 Takeout \u5bfc\u51fa\u6570\u636e\u7136\u540e\u4e0b\u8f7d\u4e0b\u6765\uff0c\u5305\u542b\u539f\u59cb\u6587\u4ef6\u548c\u7528 json \u5f62\u5f0f\u5b58\u50a8\u7684 meta \u4fe1\u606f\u3002QQ \u548c Dingtalk \u4e4b\u7c7b\u7684\u9700\u8981\u53bb\u7ffb\u8f6f\u4ef6\u7684\u6570\u636e\u5b58\u50a8\u76ee\u5f55\uff0cWechat \u6211\u60f3\u641e\u4f46\u8fd8\u6ca1\u627e\u5230\u5408\u9002\u7684\u5bfc\u51fa\u6570\u636e\u65b9\u6cd5\u2026\u2026<\/li>\n\n\n\n<li>\u56fe\u7247\u5b58\u50a8\uff1a\u7531\u4e8e QQ \u7fa4\u804a\u56fe\u7247\u6570\u91cf\u5de8\u5927\uff0c\u56e0\u6b64\u627e\u4e86\u5757\u5783\u573e SSD \u7528\u6765\u5b58\u50a8\uff0c\u76f4\u63a5\u5b58\u5230\u6587\u4ef6\u7cfb\u7edf\u4e0a\u9762\uff0c\u8003\u8651\u53bb\u91cd\u56fe\u50cf\u4f1a\u8ba1\u7b97\u4e00\u4e2a MD5 Hash\u3002<\/li>\n\n\n\n<li>\u7279\u5f81\u63d0\u53d6\uff1a\u4f7f\u7528\u7684\u662f Github \u4e0a OpenAI \u5b98\u65b9\u7684 <a href=\"https:\/\/github.com\/openai\/CLIP\">CLIP \u5e93<\/a>\u3002\u8ba1\u7b97\u7279\u5f81\u524d\u56fe\u7247\u4f1a Center Crop \u5230 224&#215;224 \u5c3a\u5bf8\u3002\u4f7f\u7528\u4e86 <code>\"ViT-L\/14\"<\/code> \u6a21\u578b\uff0c\u8f93\u51fa 768 \u7ef4\u7684 Feature\u3002<\/li>\n\n\n\n<li>\u7279\u5f81\u5b58\u50a8\uff1a\u7528\u4e86 MongoDB\uff08\u5bf9\u7740 ChatGPT \u73b0\u5b66\u7684\uff09\uff0c\u7279\u5f81\u5b9e\u9645\u4e0a\u662f FP16 \u7c7b\u578b\u6240\u4ee5\u4e00\u5f20\u56fe\u7684\u7279\u5f81\u662f 1536 \u5b57\u8282\uff0c\u5982\u679c\u4f7f\u7528\u5c0f\u4e00\u70b9\u7684\u6a21\u578b\u7279\u5f81\u4e5f\u53ef\u4ee5\u66f4\u5c0f\u3002<\/li>\n\n\n\n<li>\u641c\u7d22\u524d\u7aef\uff1a\u73b0\u5b66\u4e86 Gradio\uff0c\u505a\u8fd9\u7c7b Demo \u8fd8\u633a\u597d\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u7279\u5f81\u63d0\u53d6\u4e0e\u5165\u5e93<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u5728 CUDA \u4e0a\u8dd1\u7684\u65f6\u5019\u9ed8\u8ba4\u8f93\u51fa\u662f FP16\uff0c\u800c CPU \u4e0a\u7684\u6a21\u578b\u8c03\u7528\u5c31\u53ea\u80fd\u8f93\u51fa FP32 \u4e86\uff0c\u5982\u679c\u540e\u9762\u8981\u5728 CPU \u4e0a\u7ee7\u7eed\u5904\u7406\u7684\u8bdd\u9700\u8981\u5bf9\u9f50\u4e00\u4e0b\u7c7b\u578b<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CLIP_MODEL = \"ViT-L\/14\"\nIMAGE_DIR = \"\/mnt\/e\/temp\/iphone-import\"\nCLIP_MODEL_DOWNLOAD_ROOT = \"\/home\/andy\/dev\/CLIP-dev\/model\"\n\ndef main():\n    IMAGE_PATH_LIST = sorted(glob(os.path.join(IMAGE_DIR, \"*.*\")))\n    IMAGE_PATH_LIST = [i for i in IMAGE_PATH_LIST if not (i.endswith(\".GIF\") or i.endswith(\".MP4\") or i.endswith(\"AAE\"))]\n    print(\"Found {} images\".format(len(IMAGE_PATH_LIST)))\n\n    device = \"cuda\"\n\n    model, preprocess = clip.load(CLIP_MODEL, device=device, download_root=CLIP_MODEL_DOWNLOAD_ROOT)\n    feature_dict = {}\n\n    for image_path in tqdm(IMAGE_PATH_LIST):\n        image_basename = os.path.basename(image_path)\n\n        image = preprocess(Image.open(image_path))\n        image = image.unsqueeze(0).to(device)\n\n        with torch.no_grad():\n            image_feat = model.encode_image(image)\n            image_feat = image_feat.detach().cpu().numpy()  # It is still FP16 on CPU Here\n\n        feature_dict[image_basename] = image_feat<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5165\u5e93\u65f6\u4f1a\u540c\u65f6\u5305\u542b\u56fe\u7247\u7684\u521b\u5efa\u65e5\u671f\u3001\u5c3a\u5bf8\u3001\u6269\u5c55\u540d\u7b49\uff0c\u65b9\u4fbf\u540e\u9762\u68c0\u7d22\u7528<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">image_feat_bytes = image_feat.tobytes()\nstat = os.stat(image_path)\nimage_filesize = stat.st_size\nimage_mtime = datetime.fromtimestamp(stat.st_mtime)\nimage_datestr = image_mtime.strftime(\"%Y-%m-%dT%H:%M:%S.%fZ\")\n\nimage_width, image_height = image_shape\n\ndocument = {\n    'filename': os.path.basename(image_path),\n    'extension': image_path.split(\".\")[-1],\n    'importance': TARGET_IMPORTANCE,\n    'height': image_height,\n    'width': image_width,\n    'filesize': image_filesize,\n    'date': image_datestr,\n    'feature': image_feat_bytes,\n}\n\nx = collection.insert_one(document)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u68c0\u7d22\u4e0e\u524d\u7aef\u8bbe\u8ba1<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u524d\u68c0\u7d22\u662f\u4ece MongoDB \u4e0a\u4e00\u53e3\u6c14\u628a\u5168\u90e8\u7279\u5f81\u90fd fetch \u4e0b\u6765\u7136\u540e\u76f4\u63a5\u7b97 cosine distance\u3002\u65f6\u95f4\u57fa\u672c\u4f1a\u82b1\u5728 MongoDB \u7684\u68c0\u7d22\u4e0a\u9762\u3002\u68c0\u7d22\u8fd9\u91cc\u57fa\u672c\u601d\u8def\u5c31\u662f\u6309\u7167\u8ddd\u79bb\u6392\u5e8f\uff0c\u7b97\u662f\u4efb\u4f55\u68c0\u7d22\u7cfb\u7edf\u90fd\u4f1a\u7528\u5230\u7684\u6838\u5fc3\u4ee3\u7801\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u68c0\u7d22\u5f15\u5165\u4e86\u4e0a\u9762\u6211\u4eec\u8003\u8651\u5230\u7684\u201c\u6839\u636e\u56fe\u50cf meta \u4fe1\u606f\u505a\u9884\u7b5b\u9009\u201d\u7684\u6761\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cos_similarity = torch.nn.CosineSimilarity(dim=1, eps=1e-6)\n\ndef calc_cpu_compare(query_feature, feature_list):\n    time_start = time.time()\n    feature_list = torch.from_numpy(feature_list.astype('float32'))\n    sim_score = cos_similarity(query_feature, feature_list).detach().numpy()\n    time_end = time.time()\n    # print(\"[DEBUG] calculate cos distance {} for {:.6f}s\".format(feature_list.shape, (time_end - time_start)))\n    return sim_score\n\ndef search_nearest_image_feature(\n        query_feature,\n        topn=20,\n        minimum_width=0, minimum_height=0,\n        minimum_importance=0, extension_choice=[],\n        mongo_collection=None):\n    assert isinstance(minimum_height, int) and isinstance(minimum_width, int)\n    assert mongo_collection is not None\n    # find all image filename and features\n    mongo_query_dict = {}\n    if minimum_width > 0:\n        mongo_query_dict[\"width\"] = {\"$gte\": minimum_width}\n    if minimum_height > 0:\n        mongo_query_dict[\"height\"] = {\"$gte\": minimum_height}\n    if minimum_importance > 0:\n        mongo_query_dict[\"importance\"] = {\"$gte\": minimum_importance}\n    if len(extension_choice) > 0:\n        mongo_query_dict[\"extension\"] = {\"$in\": extension_choice}\n    \n    cursor = mongo_collection.find(mongo_query_dict, {\"_id\": 0, \"filename\": 1, \"feature\": 1})\n\n    with torch.no_grad():\n        if DEVICE == \"cpu\":\n            feature_list = []\n            filename_list = []\n            sim_score_list = []\n            query_feature = query_feature.astype('float32').reshape(1, 768)\n            query_feature = torch.from_numpy(query_feature)\n\n            for doc in cursor:\n                feature_list.append(np.frombuffer(doc[\"feature\"], \"float16\"))\n                filename_list.append(doc[\"filename\"])\n\n                if len(feature_list) >= MAX_SPLIT_SIZE:\n                    feature_list = np.array(feature_list)\n                    sim_score_list.append(calc_cpu_compare(query_feature, feature_list))\n                    feature_list = []\n                    # filename_list = []\n            if len(feature_list) > 0:\n                feature_list = np.array(feature_list)\n                sim_score_list.append(calc_cpu_compare(query_feature, feature_list))\n\n            if len(sim_score_list) == 0:\n                return [], []\n\n            sim_score = np.concatenate(sim_score_list, axis=0)\n            print(\"[DEBUG] len(sim_score) = {}\".format(len(sim_score)))\n\n    top_n_idx = np.argsort(sim_score)[::-1][:topn]\n    top_n_filename = [filename_list[idx] for idx in top_n_idx]\n    top_n_score = [sim_score[idx] for idx in top_n_idx]\n\n    return top_n_filename, top_n_score<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u524d\u7aef\u8fd9\u91cc\u4f7f\u7528\u4e86 Gradio\uff0c\u611f\u89c9\u975e\u5e38\u9002\u5408\u4e2a\u4eba\u505a Demo \u7528\uff0c\u81ea\u5e26\u7684 Image \u63a7\u4ef6\u652f\u6301\u62d6\u62fd\u5bfc\u5165\u4e5f\u975e\u5e38\u9002\u5408\u6211\u4eec\u7684\u56fe\u641c\u56fe\u573a\u666f\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">with gr.Blocks() as demo:\n    heading = gr.Markdown(\"# CLIP Image Search Demo\")\n    \n    # Use tabs\n    with gr.Tab(\"Using prompt and CLIP feature\"):\n        prompt_textbox = gr.Textbox(lines=4, label=\"Prompt\")\n        button_prompt = gr.Button(\"Search\").style(size=\"lg\")\n    with gr.Tab(\"Using image and CLIP feature\"):\n        input_image = gr.Image(label=\"Image\", type=\"pil\")\n        button_image = gr.Button(\"Search\").style(size=\"lg\")\n\n    with gr.Accordion(\"Search options\", open=False):\n        extension_choice = gr.CheckboxGroup([\"jpg\", \"png\", \"gif\"], label=\"extension\", info=\"choose extension for search\")\n        with gr.Row():\n            topn = gr.Number(value=64, label=\"topn\")\n            minimum_width = gr.Number(value=0, label=\"minimum_width\")\n            minimun_height = gr.Number(value=0, label=\"minimum_height\")\n            minimun_importance = gr.Number(value=0, label=\"minimum_importance\")\n\n    gr_gallery = gr.Gallery(label=\"results\").style(grid=4, height=6)\n\n    button_prompt.click(submit, inputs=[prompt_textbox, topn, minimum_width, minimun_height, minimun_importance, extension_choice], outputs=[gr_gallery])\n    button_image.click(submit, inputs=[input_image, topn, minimum_width, minimun_height, minimun_importance, extension_choice], outputs=[gr_gallery])\n\ndemo.launch()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u6027\u80fd\u5206\u6790<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u5206\u6210\u4e24\u90e8\u5206\uff0c\u4e00\u4e2a\u662f\u6574\u4e2a\u6570\u636e\u5e93\u521d\u59cb\u5316\u7684\u64cd\u4f5c\uff0c\u53e6\u4e00\u4e2a\u662f\u6570\u636e\u5e93\u5efa\u597d\u4e4b\u540e\u7684\u68c0\u7d22\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5efa\u5e93\u5176\u5b9e\u6bd4\u8f83\u82b1\u65f6\u95f4\uff0c\u6211\u5728 Windows 10 \u7684 WSL \u4e0b\u8dd1\u7684 CUDA\uff0c\u5177\u4f53\u6570\u5b57\u4e0d\u592a\u8bb0\u5f97\uff0c\u4f46\u5927\u6982\u662f\u4e00\u5c0f\u65f6\u8dd1 100k \u6570\u91cf\u56fe\u7247\u7684\u91cf\u7ea7\u3002\u6211\u6574\u4e2a\u6570\u636e\u5e93\u5168\u8dd1\u5b8c\u5927\u6982\u8981\u534a\u5929\u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u68c0\u7d22\u7684\u65f6\u95f4\u5f88\u5927\u4e00\u90e8\u5206\u6765\u81ea\u4e8e MongoDB \u67e5\u627e\uff08\u628a\u767e\u4e07\u91cf\u7ea7\u7684 feature \u62ff\u51fa\u6765\uff09\u3002\u800c\u7b97\u7279\u5f81\u8ddd\u79bb\u7684\u901f\u5ea6\uff0c\u6211\u5b9e\u6d4b\u6bcf 8192 \u5f20\u56fe\u9700\u8981 20ms \u5de6\u53f3\uff0c\u767e\u4e07\u91cf\u7ea7\u56fe\u7247\u5168\u7b97\u4e00\u904d\u8ddd\u79bb\u9700\u8981 2~3s\uff0c\u4f30\u8ba1\u8fd8\u6709\u4e0d\u5c11\u4f18\u5316\u7a7a\u95f4\u3002\u6700\u540e\u5b8c\u6574\u5b9e\u6d4b\uff0c\u4e00\u6b21\u5168\u91cf\u641c\u7d22\u8ba1\u7b97\u767e\u4e07\u7279\u5f81\u8ddd\u7136\u540e\u627e\u51fa top N \u5728\u6211 NAS \u7684 i3-10105T CPU \u4e0b\u9700\u8981 6~7s \u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8dd1\u670d\u52a1\u7684\u8bdd\uff0c\u56e0\u4e3a CLIP \u6a21\u578b\u8981\u5e38\u9a7b\u5185\u5b58\uff0c\u6211\u7528\u7684 &#8220;ViT-L\/14&#8221; \u6bd4\u8f83\u5927\uff0c\u5927\u6982\u8981\u5360\u7528 2~3GB \u7684\u5185\u5b58\uff0c\u52a0\u4e0a mongodb \u4e5f\u8981\u5360\u7528 1~2GB\uff0c\u4e0d\u5c11 NAS \u53ef\u80fd\u6709\u4e9b\u5403\u529b\uff0c\u4f46 PC \u4e00\u822c\u95ee\u9898\u4e0d\u5927\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6548\u679c\u5c55\u793a\u4e0e\u5410\u69fd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u662f\u6211\u53d1\u73b0 CLIP \u6a21\u578b\u662f\u6709\u4e00\u5b9a OCR \u80fd\u529b\u7684\u3002\u6211\u5148\u5c1d\u8bd5\u641c\u7d22\u4e86\u4e00\u4e2a &#8220;anime screenshot with captions&#8221; \u60f3\u641c\u4e00\u4e9b\u52a8\u753b\u622a\u56fe\u3002\u53d1\u73b0\u7b2c\u4e00\u5f20\u56fe\u91cc\u9762\u7684\u82f1\u6587\u6587\u672c\u662f &#8220;Your code&#8217;s buggy. We can&#8217;t sell this product.&#8221;\uff0c\u795e\u5947\u7684\u662f\u7adf\u7136\u53ef\u4ee5\u7528\u8fd9\u4e32\u6587\u5b57\u4e5f\u641c\u5230\u540c\u6837\u7684\u56fe\u3002\u611f\u89c9 CLIP \u6a21\u578b\u4e5f\u4e0d\u7b97\u7279\u522b\u5927\uff0c\u7adf\u7136\u5df2\u7ecf\u8bad\u7ec3\u51fa\u6765\u8fd8\u4e0d\u9519\u7684 OCR \u80fd\u529b\u4e86\u3002\u53ef\u60dc\u5c31\u662f CLIP \u5bf9\u4e2d\u6587\u7406\u89e3\u80fd\u529b\u51e0\u4e4e\u4e3a\u96f6\u5b8c\u5168\u6ca1\u6cd5\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"1024\" data-id=\"257\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234340-791x1024.webp\" alt=\"\" class=\"wp-image-257\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234340-791x1024.webp 791w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234340-232x300.webp 232w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234340-768x994.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234340-1187x1536.webp 1187w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234340-jpg.webp 1283w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><figcaption class=\"wp-element-caption\">\u5148\u641c\u7d22 anime screenshot<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"1024\" data-id=\"258\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234538-799x1024.webp\" alt=\"\" class=\"wp-image-258\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234538-799x1024.webp 799w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234538-234x300.webp 234w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234538-768x984.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234538-1199x1536.webp 1199w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326234538-jpg.webp 1297w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><figcaption class=\"wp-element-caption\">\u518d\u5c1d\u8bd5\u641c\u7d22\u5b57\u5e55\u5185\u5bb9<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53e6\u5916\u6211\u8fd8\u53d1\u73b0\uff0c\u6709\u4e86\u767e\u4e07\u91cf\u7ea7\u7684 QQ \u7fa4\u804a\u8bb0\u5f55\u4e4b\u540e\uff0c\u8fd9\u4e2a\u641c\u7d22\u5f15\u64ce\u975e\u5e38\u9002\u5408\u641c meme \u8868\u60c5\u5305\u8fd8\u6709\u52a8\u753b\u89d2\u8272\u3002\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e9b\u8868\u60c5\u5305\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"1024\" data-id=\"248\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-552x1024.webp\" alt=\"\" class=\"wp-image-248\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-552x1024.webp 552w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-162x300.webp 162w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-768x1425.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-828x1536.webp 828w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-1104x2048.webp 1104w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326231857-jpg.webp 1265w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"551\" height=\"1024\" data-id=\"249\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-551x1024.webp\" alt=\"\" class=\"wp-image-249\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-551x1024.webp 551w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-162x300.webp 162w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-768x1426.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-827x1536.webp 827w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-1103x2048.webp 1103w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232240-jpg.webp 1268w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"557\" height=\"1024\" data-id=\"250\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-557x1024.webp\" alt=\"\" class=\"wp-image-250\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-557x1024.webp 557w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-163x300.webp 163w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-768x1412.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-836x1536.webp 836w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-1114x2048.webp 1114w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232414-jpg.webp 1281w\" sizes=\"auto, (max-width: 557px) 100vw, 557px\" \/><\/figure>\n<figcaption class=\"blocks-gallery-caption wp-element-caption\">\u901a\u8fc7\u4e00\u5f20\u56fe\u627e\u51fa\u7c7b\u4f3c\u7684\u56fe\u7247\uff0cCLIP \u81ea\u7136\u800c\u7136\u5c31\u4f1a\u627e\u5230\u201c\u8bed\u4e49\u201d\u4e0a\u66f4\u63a5\u8fd1\u7684\u56fe\uff0c\u8fd9\u4e2a\u6548\u679c\u662f\u6bd4\u4e4b\u524d\u7eaf\u56fe\u50cf\u7279\u5f81\u8981\u597d\u5f88\u591a\u7684<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53e6\u5916\u6211\u4e5f\u5c1d\u8bd5\u7ed9\u5b83\u4e00\u4e9b\u6ca1\u89c1\u8fc7\u7684\u52a8\u753b\u89d2\u8272\uff08\u8fdc\u665a\u4e8e\u6a21\u578b\u51fa\u73b0\u65f6\u95f4\u7684\u89d2\u8272\uff09\uff0c\u5b83\u4e5f\u4f3c\u4e4e\u80fd\u201c\u8ba4\u8bc6\u201d\u8fd9\u4e9b\u89d2\u8272\u5e76\u4e14\u7ed3\u679c\u4e0a\u641c\u7d22\u51fa\u76f8\u540c\u89d2\u8272\u7684\u56fe\u7247\u3002<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"1024\" data-id=\"254\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-631x1024.webp\" alt=\"\" class=\"wp-image-254\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-631x1024.webp 631w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-185x300.webp 185w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-768x1246.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-947x1536.webp 947w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-1263x2048.webp 1263w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326232852-3-jpg.webp 1283w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><figcaption class=\"wp-element-caption\">\u30df\u30ab\uff0c\u6211\u7684\u30df\u30ab.jpg<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"1024\" data-id=\"256\" src=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-609x1024.webp\" alt=\"\" class=\"wp-image-256\" srcset=\"https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-609x1024.webp 609w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-178x300.webp 178w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-768x1291.webp 768w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-914x1536.webp 914w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-1218x2048.webp 1218w, https:\/\/andy9999678.me\/blog\/wp-content\/uploads\/2023\/03\/QQ\u622a\u56fe20230326233224-jpg.webp 1271w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u7ba1\u6a21\u578b\u662f\u4e0d\u662f\u771f\u6b63\u77e5\u9053\u89d2\u8272\u7684\u5b9a\u4e49\uff0c\u4f46\u81f3\u5c11\u6a21\u578b\u80fd\u901a\u8fc7\u8bed\u4e49\u4e0a\u627e\u51fa\u65b0\u7684\u56fe\u7247\u540c\u6837\u5305\u542b\u65e7\u56fe\u7247\u4e0a\u7684\u5143\u7d20\u3002\u8fd9\u4e9b\u7ec4\u5408\u5176\u5b9e\u6b63\u662f\u4eba\u7c7b\u5bf9\u4e00\u4e2a\u65b0\u89d2\u8272\u7684\u5b9a\u4e49\uff0c\u80fd\u5b9e\u73b0\u8fd9\u6837\u7a0b\u5ea6\u7684\u68c0\u7d22\u5df2\u7ecf\u975e\u5e38\u4ee4\u4eba\u60ca\u559c\u4e86\u3002\u800c\u4ee5\u524d\u6211\u770b\u5230\u7684\u201c\u56fe\u641c\u56fe\u201d\u66f4\u591a\u8fd8\u662f\u5728\u4f20\u7edf\u56fe\u50cf\u7279\u5f81\u7684\u7a7a\u95f4\u4e0a\u627e\u8fd1\u90bb\uff0c\u73b0\u5728\u6a21\u578b\u76f8\u6bd4\u4e4b\u4e0b\u66f4\u50cf\u662f\u201c\u7406\u89e3\u4e86\u56fe\u7247\u7684\u5185\u5bb9\u4e86\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6700\u540e\u8fd8\u6709\u4e00\u4e2a\u503c\u5f97\u6ce8\u610f\u7684\u73b0\u8c61<\/strong>\uff1a\u5728\u6211\u5c1d\u8bd5\u7528\u6587\u5b57\u641c\u56fe\u7684\u65f6\u5019\uff0c\u76f8\u4f3c\u5ea6\u57fa\u672c\u53ea\u6709 0.2~0.3\uff0c0.3 \u5c31\u5df2\u7ecf\u662f\u975e\u5e38\u9ad8\u7684\u76f8\u4f3c\u5ea6\u4e86\u3002\u800c\u7528\u56fe\u7247\u641c\u56fe\u7684\u65f6\u5019 0.8~0.9 \u7684\u76f8\u4f3c\u5ea6\u90fd\u5341\u5206\u5e38\u89c1\u3002\u8fd9\u91cc\u9762\u6709\u51e0\u4e2a\u89e3\u91ca\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u67d0\u540c\u5b66\u5f3a\u8c03\u56fe\u50cf\u7684 Space \u4e0e\u6587\u672c\u7684 Space \u8fd8\u662f\u6709 bias\uff0c\u8de8\u6a21\u6001\u9700\u8981\u5bf9\u9f50\u624d\u80fd\u8fbe\u5230\u66f4\u597d\u7684\u6548\u679c\u3002\u540c\u6a21\u6001\u5bf9\u6bd4\u76f8\u4f3c\u5ea6\u9ad8\u800c\u8de8\u6a21\u6001\u76f8\u4f3c\u5ea6\u4f4e\u662f\u5f88\u6b63\u5e38\u7684\u3002<\/li>\n\n\n\n<li>\u800c\u6211\u7684\u89c2\u70b9\u662f\uff0c\u56fe\u50cf\u5305\u542b\u7684\u4fe1\u606f\u663e\u7136\u4e0d\u662f\u51e0\u4e2a\u5355\u8bcd\u5c31\u80fd\u63cf\u8ff0\u6e05\u695a\u7684\uff0c\u6bd4\u5982\u6b63\u5e38\u62cd\u4e00\u4e2a\u4eba\u50cf\u7167\u7247\uff0c\u53ef\u80fd\u7b80\u5355\u7684\u63cf\u8ff0\u5c31\u662f<span style=\"text-decoration: underline;\">\u8fd9\u4e2a\u4eba\u662f\u8c01<\/span>\uff0c<span style=\"text-decoration: underline;\">\u957f\u4ec0\u4e48\u6837\u5b50<\/span>\uff1b\u4f46\u5b9e\u9645\u4e0a\u8fd8\u6709\u5f88\u591a\u4e0d\u5728\u8fd9\u4e2a\u63cf\u8ff0\u91cc\u7684\u4fe1\u606f\u4e5f\u4f1a\u88ab\u8ba1\u7b97\u8fdb Feature \u91cc\u9762\uff0c\u6bd4\u5982\u80cc\u666f\u6709\u4ec0\u4e48\u5185\u5bb9\uff0c\u56fe\u50cf\u7684\u6e05\u6670\u5ea6\u5982\u4f55\uff0c\u6709\u6ca1\u6709\u5927\u5149\u5708\u5e26\u6765\u7684\u865a\u5316\uff0c\u4eba\u7a7f\u4e86\u54ea\u4e9b\u8863\u670d\u54ea\u4e9b\u624b\u52bf\uff0c\u6709\u4ec0\u4e48\u8868\u60c5\u59ff\u52bf\u7b49\u7b49\u3002\u56e0\u6b64\u6587\u5b57\u5230\u56fe\u7247\u7684\u5bf9\u6bd4\u5b9e\u9645\u4e0a\u662f\u3010\u6700\u6709\u4ee3\u8868\u6027\u7684\u63cf\u8ff0\u3011\u53bb\u6bd4\u5bf9\u3010\u5bf9\u56fe\u7247\u5c3d\u53ef\u80fd\u5b8c\u5168\u7684\u5168\u91cf\u63cf\u8ff0\u3011\uff0c\u81ea\u7136\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6587\u5b57\u5bf9\u56fe\u7247\u7684\u8ddd\u79bb\u66f4\u8fdc\uff0c\u800c\u56fe\u4e0e\u56fe\u4e4b\u95f4\u7684\u8ddd\u79bb\u66f4\u8fd1\u4e86\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Limitations and TODO<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CLIP \u6a21\u578b\u5b8c\u5168\u4e0d\u80fd\u7406\u89e3\u82f1\u8bed\u4e4b\u5916\u7684\u8bed\u8a00\uff0cprompt \u53ea\u80fd\u5199\u82f1\u8bed\uff0c\u4e2d\u6587\u65e5\u6587\u90fd\u6293\u778e\uff08\u4f46\u662f\u6709 <a href=\"https:\/\/github.com\/OFA-Sys\/Chinese-CLIP\">Chinese-CLIP<\/a> \u6216\u8bb8\u4e5f\u80fd\u7528\uff1f\uff09\u3002<\/li>\n\n\n\n<li>CLIP \u6a21\u578b\u8fd8\u662f\u6709\u4e9b\u9650\u5236\u7684\u3002224&#215;224 \u7684 Center Crop \u5bfc\u81f4\u5b83\u5176\u5b9e\u4e0d\u4f1a\u5904\u7406\u88ab Crop \u6389\u7684\u8fb9\u7f18\u4fe1\u606f\u3002\u641c\u56fe\u7684\u65f6\u5019\u4f1a\u56e0\u6b64\u4e22\u7ed3\u679c\u3002<\/li>\n\n\n\n<li>\u73b0\u5728\u6211\u4eec\u53d1\u73b0 CLIP \u6a21\u578b\u6709\u4e00\u5b9a\u7684 OCR \u80fd\u529b\u4e86\uff0c\u4f46\u4f3c\u4e4e\u8fd8\u4e0d\u592a\u591f\uff08\u4e5f\u5305\u62ec\u5b83\u53ea\u80fd\u7406\u89e3\u82f1\u8bed\uff09\u3002\u5982\u679c\u60f3\u51c6\u786e\u67e5\u8be2\u56fe\u7247\u91cc\u7684\u6587\u5b57\uff08\u6bd4\u5982\u627e\u4e2a\u540d\u5b57\u3001\u624b\u673a\u53f7\u3001\u8eab\u4efd\u8bc1\u53f7\u4e4b\u7c7b\u7684\uff09\uff0c\u6211\u5e0c\u671b\u80fd\u5f15\u5165 OCR + \u6587\u5b57\u68c0\u7d22\u529f\u80fd\uff0c\u66f4\u597d\u5730\u5b9e\u73b0\u6211\u4e2a\u4eba\u201c\u627e\u56fe\u201d\u7684\u9700\u6c42\u3002\u8fd9\u4e2a\u5df2\u7ecf\u5728\u505a\u4e86\u800c\u4e14\u53ef\u4ee5\u518d\u6c34\u4e00\u7bc7 Blog\uff08\uff1f\uff09\u3010Update\uff1a<a href=\"https:\/\/andy9999678.me\/blog\/?p=275\">\u5df2\u66f4\u65b0<\/a>\u3011<\/li>\n\n\n\n<li>\u5982\u679c\u80fd\u8ba9\u6211\u770b\u8fc7\u7684\u56fe\uff08\u4e0d\u53ea QQ \u7fa4\uff09\uff0c\u5305\u62ec\u5fae\u4fe1\u3001Twitter \u7b49\u56fe\u7247\u6765\u6e90\u90fd\u80fd\u81ea\u52a8\u5165\u5e93\u7684\u8bdd\uff0c\u6211\u540e\u9762\u627e\u56fe\u7684\u56fe\u5e93\u4f1a\u5927\u5f88\u591a\u3002\u9700\u8981\u4e00\u4e2a\u81ea\u52a8\u5bfc\u5165\u7684\u6a21\u5757\u3002<\/li>\n\n\n\n<li>\u771f\u6b63\u753b\u997c\u7684\u8bdd\uff0c\u6211\u5e0c\u671b ChatGPT \u7ea7\u522b\u7684\u667a\u80fd\u53ef\u4ee5\u6709\u66f4\u5f3a\u7684\u5904\u7406\u79c1\u4eba\u4fe1\u606f\u7684\u80fd\u529b\uff0c\u80fd\u591f\u603b\u7ed3\u548c\u68c0\u7d22\u8de8\u6a21\u6001\u7684\u4fe1\u606f\uff08\u56fe\u50cf\u6587\u5b57\u58f0\u97f3\u89c6\u9891\uff09\u3002\u6700\u8fd1\u770b plugin \u51fa\u6765 ChatGPT Plugins \u91cc\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a\u53ef\u4ee5\u5403\u5230\u5916\u90e8\u4fe1\u606f\u7684 API \u5b9e\u73b0: <a href=\"https:\/\/github.com\/openai\/chatgpt-retrieval-plugin\">ChatGPT Retrieval Plugin<\/a>\uff0c\u5982\u679c\u8fd9\u4e2a\u80fd\u529b\u80fd\u96c6\u6210\u5230\u5f00\u6e90\u6a21\u578b\u91cc\u9762\uff0c\u76f8\u4fe1\u4ee5\u540e\u7684\u5de5\u4f5c\u751f\u6d3b\u65b9\u5f0f\u4f1a\u53d1\u751f\u5f88\u5927\u7684\u53d8\u5316\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CLIP \u7684 Paper: <a href=\"https:\/\/arxiv.org\/abs\/2103.00020\">Learning Transferable Visual Models From Natural Language Supervision<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/apps.apple.com\/us\/app\/queryable-find-photo-by-text\/id1661598353\">Queryable<\/a> \/ <a href=\"https:\/\/apps.apple.com\/cn\/app\/%E5%AF%BB%E9%9A%90-%E7%94%A8%E6%96%87%E5%AD%97%E6%89%BE%E7%85%A7%E7%89%87\/id1664361663\">\u5bfb\u9690<\/a> App \u4ee5\u53ca\u80cc\u540e\u7684<a href=\"https:\/\/sspai.com\/post\/77862\">\u5f00\u53d1\u8fc7\u7a0b<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Update: \u5df2\u7ecf\u66f4\u65b0 Github \u4ee3\u7801: https:\/\/github.com\/atarss\/clip- &hellip; <a href=\"https:\/\/andy9999678.me\/blog\/archives\/239\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u57fa\u4e8e CLIP \u6a21\u578b\u7279\u5f81\u642d\u5efa\u7b80\u6613\u7684\u4e2a\u4eba\u56fe\u50cf\u641c\u7d22\u5f15\u64ce<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-239","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts\/239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/comments?post=239"}],"version-history":[{"count":12,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts\/239\/revisions"}],"predecessor-version":[{"id":283,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/posts\/239\/revisions\/283"}],"wp:attachment":[{"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/media?parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/categories?post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andy9999678.me\/blog\/wp-json\/wp\/v2\/tags?post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}