blob: 7500bef96096e6556d53a4de6aad5357902d8eb7 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# VFRAME Check API
The VFRAME Check API Service uses perceptual hash to disambiguate similar images as well as provide an image-based search engine.
## Quick Start
- Install Python 3.x (use Miniconda or your choice)
- Install nginx, MySQL
```
apt install git nginx mysql-server mysql-client
mysql_secure_installation
mysql -u root -p
```
Create MySQL user:
```
CREATE DATABASE vframe_check;
CREATE USER 'vframe_check'@'localhost' IDENTIFIED BY 'some_new_password';
GRANT ALL PRIVILEGES ON vframe_check.* to 'vframe_check'@'localhost';
```
Clone the repo and add a .env file:
```
DB_HOST=localhost
DB_NAME=vframe_check
DB_USER=vframe_check
DB_PASS=some_new_password
```
The initial dataset can be hosted locally for now - make sure files are accessible inside `check/static/`. These paths will be added directly to the dataset.
```
python cli_phash.py import -i 'static/sample_set_test_01/images/*'
```
Build the Javascript frontend:
```
npm run build
```
Run the server:
```
cd check
python cli_flask.py run
```
The server will be running on http://0.0.0.0:5000/
### Endpoints
#### POST /v1/match
Check if an image is in the database. If no images are found within the threshold, this image will be added to the database.
Form parameters:
- `threshold` (default: 6) - Minimum similarity threshold. This is the Hamming distance used for phash comparisons.
- `limit` (default: 1) - Number of results to return.
- `url` - Image URL to fetch and test (will be added if not found!)
- `q` (file) - Uploaded file to test (will not be added)
#### POST /v1/similar
Find similar images to a query image.
Form parameters:
- `threshold` (default: 20) - Minimum similarity threshold.
- `limit` (default: 10) - Number of results to return.
- `url` - Image URL to fetch and test
- `q` (file) - Uploaded file to test
|