Files
webp/README.md
2023-04-12 23:19:10 +08:00

148 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# webp
提供webp生成服务
```javascript
// GET /webp/{type}-{id}-{version}-{width}-{height}-{fit}.{format}
// @type: image avatar article article_attribute ad
// @id: int 图片ID或是文章ID或是广告ID
// @version: update_time 时间戳
// @width: 宽度 1x 2x 3x 倍图直接输入尺寸
// @height: 高度 1x 2x 3x 倍图直接输入尺寸
// @fit: 裁切方式 cover contain fill auto
// GET /img/{type}-{id}.{format}?width=320&height=320&fit=cover
// 更优雅的实现, 使用查询参数的接口 (不幸的是CDN与OSS都不支持)
```
## Update
```bash
# 静态编译
go build bin/main.go
# 上传到服务器
scp ./main root@47.103.40.152:~/main
```
## Dev & Install
```bash
# 需要安装依赖
sudo apt install libopencv-dev
```
防止错误 ArucoDetector in namespace cv::aruco does not name a type
將安裝的 opencv 版本從 4.2 更改為 4.7,它工作正常。
```bash
# E: 无法定位软件包 libdc1394-22-dev
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt upgrade
sudo apt install libjasper1 libjasper-dev
# 添加主服务器
sudo gedit /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse
sudo apt-get update
sudo apt update
sudo apt upgrade
# GPT 方案
sudo add-apt-repository universe
sudo apt update
sudo apt install libdc1394-22-dev
apt search libdc1394
# 手动下载 https://pkgs.org/download/libdc1394-22
wget http://archive.ubuntu.com/ubuntu/pool/universe/libd/libdc1394-22/libdc1394-22_2.2.5-2.1_amd64.deb
sudo dpkg -i libdc1394-22_2.2.5-2.1_amd64.deb
apt search libdc1394
# 确认安装后注释 Markfile 第52行
cd gocv
make install
# 下载超时请爬墙
```
torch 模型文件
https://d2j0dndfm35trm.cloudfront.net/resnet-50.t7
https://github.com/facebookarchive/fb.resnet.torch/tree/master/pretrained
## Document
通用权重模型接口
### 获取图片列表(标准查询)
GET /api/images
```javascript
{
page: 1, // 当前页码
pageSize: 20, // 分页数
next: true, // 是否存在下一页
list: [
{
id: 1234, // 原图ID
width: 512, // 原图宽度
height: 512, // 原图高度
user: { // 来源用户
id: 1234,
user_name: 'LAST',
},
article: { // 来源文章
id: 1234,
title: 'GAMEX',
}
}
]
}
```
列表视图:(输出控制)
---------------------------------------------------------------------
Method | URL | Info
-------|--------------------------------|----------------------------
GET | /api/images | 标准顺序查询
GET | /api/images?page=1&pageSize=20 | 指定页码和指定分页大小
筛选规则:(数据过滤)
---------------------------------------------------------------------
Method | URL | Info
-------|--------------------------------|----------------------------
GET | /api/images?user=1234 | 筛选指定某用户发表的图片
GET | /api/images?choice=1234 | 筛选指定精选集下的图片
GET | /api/images?like=1234 | 筛选指定用户点赞的图片
GET | /api/images?tag=1234 | 筛选含有指定标签的图片
GET | /api/images?tag=1234,1235 | 筛选含有多个标签之一的图片(并集)
GET | /api/images?tag=1234&tag=1235 | 筛选含有指定多个标签的图片(交集)
GET | /api/images?user=1234&tag=123 | 筛选指定用户的指定标签图片(交集)
GET | /api/images?date=20220214+ | 时间范围(之后)
GET | /api/images?date=20220214- | 时间范围(之前)
GET | /api/images?date=2022~2023 | 时间范围(之间)
排序规则:(权重强化)
---------------------------------------------------------------------
Method | URL | Info
-------|--------------------------------|----------------------------
GET | /api/images?sort=date+ | 排序规则(相似图片查询时此项无效)
GET | /api/images?sort=like | 根据用户偏好推荐(指定用户的偏好)
GET | /api/images?sort=history | 根据浏览记录推荐(指定用户的记录)
GET | /api/images?sort=choice | 根据精选集推荐(指定精选集ID, 取一组权重)
GET | /api/images?similar=1234 | 根据指定图片的相似图片(指定图片ID)
* 注意, 筛选规则为多条件取交集, 单条件的复数取并集
* 权重强化属于排序规则而非过滤规则