Skip to content

Commit 794f42b

Browse files
author
ManuelFay
committed
move api inside package
1 parent afec09f commit 794f42b

File tree

8 files changed

+39
-17
lines changed

8 files changed

+39
-17
lines changed

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,45 @@ group pictures, screenshots, etc...
1111

1212
## Setup
1313

14-
In a new Python 3.8+ virtual environment run:
14+
In a Python 3.8+ virtual environment, install either from PIP or from source:
15+
16+
####Installation from the PIP package:
17+
```bash
18+
pip install image-searcher
19+
20+
pip install face_recognition # Optional to enable face features
21+
pip install flask flask_cors # Optional to enable a flask api
22+
```
23+
24+
#### Installation from source
1525
```bash
1626
pip install -r dev_requirements.txt
17-
pip install face_recognition # Optional
27+
28+
pip install face_recognition # Optional to enable face features
29+
pip install flask flask_cors # Optional to enable a flask api
1830
```
1931

2032
Troubleshooting: If problems are encountered building wheels for dlib during the face_recognition installation, make sure to install the `python3.8-dev`
2133
package (respectively `python3.x-dev`) and recreate the virtual environment from scratch with the aforementionned command
2234
once it is installed.
2335

2436
## Usage
25-
Currently, the usage is as follows. It computes the embeddings of all images one by one, and stores them in
37+
Currently, the usage is as follows. The library first computes the embeddings of all images one by one, and stores them in
2638
a picked dictionary for further reference. To compute and store information about the persons in
2739
the picture, enable the `include_faces` flag (note that it makes the indexing process up to 10x slower).
2840

2941
```python
3042
from image_searcher import Search
3143

3244
searcher = Search(image_dir_path="/home/manu/perso/ImageSearcher/data/", traverse=True, include_faces=False)
45+
```
46+
47+
Once this process has been done once, through Python, the library is used as such:
48+
```python
49+
from image_searcher import Search
50+
51+
searcher = Search(image_dir_path="/home/manu/perso/ImageSearcher/data/", traverse=True, include_faces=False)
52+
3353
ranked_images = searcher.rank_images("A photo of a bird.", n=5)
3454

3555
# Display best images
@@ -71,16 +91,15 @@ threaded:
7191
```
7292
#### Start a server:
7393
```python
74-
from api.run_flask_command import RunFlaskCommand
94+
from image_searcher.api import run
7595

76-
command = RunFlaskCommand(config_path="/home/manu/perso/ImageSearcher/api/api_config.yml")
77-
command.run()
96+
run(config_path="path_to_config_file.yml")
7897
```
7998

8099
A gunicorn process can also be launched locally with:
81100

82101
```bash
83-
gunicorn "api.run_flask_gunicorn:create_app('/home/manu/perso/ImageSearcher/api/api_config.yml')" \
102+
gunicorn "api.run_flask_gunicorn:create_app('path_to_config_file.yml')" \
84103
--name image_searcher \
85104
--bind 0.0.0.0:${GUNICORN_PORT:-5000} \
86105
--worker-tmp-dir /dev/shm \

api/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from .run_flask_command import RunFlaskCommand
21
from .run_flask_gunicorn import create_app

api/run_flask_gunicorn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from flask import Flask
2-
from api.run_flask_command import RunFlaskCommand
2+
from image_searcher.api.run_flask_command import RunFlaskCommand
33

44

55
def create_app(config_path: str) -> Flask:

dev_requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-e .
44

55
gunicorn
6-
flask
7-
flask_cors
86

97
pylint
8+
twine
9+
unittest

image_searcher/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .run_flask_command import RunFlaskCommand, run
File renamed without changes.

api/run_flask_command.py renamed to image_searcher/api/run_flask_command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from flask_cors import CORS
77

88
from image_searcher import Search
9-
from api.flask_config import FlaskConfig
9+
from image_searcher.api.flask_config import FlaskConfig
1010

1111

1212
class RunFlaskCommand:
@@ -55,6 +55,6 @@ def run(self, start=True):
5555
return app
5656

5757

58-
if __name__ == "__main__":
59-
command = RunFlaskCommand(config_path="/home/manu/perso/ImageSearcher/api/api_config.yml")
58+
def run(config_path: str):
59+
command = RunFlaskCommand(config_path=config_path)
6060
command.run()

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
from pathlib import Path
33

44
extras = {
5-
"face_recognition": ["face_recognition"]
5+
"face_recognition": ["face_recognition"],
6+
"server": ["flask", "flask_cors"]
67
}
78

89
setup(
910
name="image-searcher",
10-
version="v0.0.1",
11+
version="v0.0.2",
1112
description="Image Searcher based on semantic query understanding for your own pictures.",
1213
long_description=(Path(__file__).parent / "README.md").read_text(),
1314
long_description_content_type='text/markdown',
1415
author="Manuel Faysse",
1516
author_email='[email protected]',
16-
download_url="https://github.com/ManuelFay/ImageSearcher/archive/refs/tags/v0.0.1.tar.gz",
17+
download_url="https://github.com/ManuelFay/ImageSearcher/archive/refs/tags/v0.0.2.tar.gz",
18+
url="https://github.com/ManuelFay/ImageSearcher",
19+
keywords=['search engine', 'image', 'image search', 'CLIP'],
1720
packages=find_packages(include=["image_searcher", "image_searcher.*"]),
1821
install_requires=[
1922
"torch",

0 commit comments

Comments
 (0)