# reverse_image_search 图片反向检索 ```urls https://www.gameui.net/api/default/create_vector?count=1024 # 预先生成指定数量的向量 https://www.gameui.net/api/default/create_index # 手动重建索引 ``` ## Intall ```bash # 先安装 milvus v2.1.4 矢量数据库 wget https://github.com/milvus-io/milvus/releases/download/v2.1.4/milvus_2.1.4-1_amd64.deb sudo apt-get update sudo dpkg -i milvus_2.1.4-1_amd64.deb sudo apt-get -f install # 查看 Milvus 及其依賴的狀態(etcd 和 MinIO) sudo systemctl status milvus sudo systemctl status milvus-etcd sudo systemctl status milvus-minio # 安装 etcdctl (管理工具) wget https://github.com/etcd-io/etcd/releases/download/v3.4.22/etcd-v3.4.22-linux-amd64.tar.gz # 解压 etcdctl 到 /bin/ # 向 ~/.bashrc 添加 export ETCDCTL_API=3 # 安装 python 包管理工具 pip sudo apt install python3-pip # 使用 venv 创建虚拟环境(注意安装路径是当前用户的 .local/bin) python3 -m venv venv source venv/bin/activate python -m pip install --upgrade pip # 为 .bashrc 设置快捷命令(使用echo或cat追加写) vim ~/.bashrc alias venv='source venv/bin/activate' source ~/.bashrc # 不使用虚拟环境的防止依赖冲突方法 pip freeze > requirements.txt pip uninstall -r requirements.txt # 安装依赖 pip3 install -r requirements.txt # 注意 python 要求 V3.9.7 版本以上 python3 src/main.py ``` 挂载对象存储服务作为存储盘 ## 批量处理工具 - [x] 使项目不依赖平台提供的服务, 易于迁移 - [x] 操作读写数据库, 不使用mysql - [x] /img/no_content.8dd8acce.png 冲突 - [x] 在上海区新建OSS实例作为磁盘挂载到服务器(用于存储缓存图) ...登录 - [x] 在服务器提供接口(设置CDN层分发) ...登录 - [x] 获取前端项目(修改列表图片三类分辨率) - [x] 通过 path 获取缩略图 - [x] 通过 articleDetails_id 获取缩略图 - [x] 图片向量无缓存时重新生成 - [ ] 提前生成原图webp以提高首次打开速度 ## RTT 1. OSS 中 gameui-webp Bucket 作为图片缓存层 2. 通过 /img/xxx.webp 接口提供图片, 由 OSS 作镜像回源 NGINX config ```config server { location /docs { proxy_pass http://gameui_ai_server; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /api/ { proxy_pass http://gameui_ai_server; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~* /img/([0-9]+)\.(webp|jpeg) { proxy_pass http://gameui_ai_server; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~* /img/([0-9]+).*\.(webp|jpeg) { proxy_pass http://gameui_ai_server; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~* /img/article-([0-9]+).*\.(webp|jpeg) { proxy_pass http://gameui_ai_server; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ```