Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented image tagging using TensorFlow InceptionV3 #28

Merged
merged 11 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dev:
docker-compose -f ./server/docker-compose.yml up
docker-compose -f ./docker/docker-compose.yml up

dev-update:
docker-compose -f ./server/docker-compose.yml up --build -V
docker-compose -f ./docker/docker-compose.yml up --build -V

dev-scale:
docker-compose -f ./server/docker-compose.yml up --build -V --scale immich_server=3 --remove-orphans
docker-compose -f ./docker/docker-compose.yml up --build -V --scale immich_server=3 --remove-orphans
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ You can use docker compose for development, there are several services that comp
2. PostgreSQL
3. Redis
4. Nginx
5. TensorFlow and Keras

## Populate .env file

Navigate to `server` directory and run
Navigate to `docker` directory and run

````
```
cp .env.example .env
```

Then populate the value in there.

Expand All @@ -59,13 +61,13 @@ Pay attention to the key `UPLOAD_LOCATION`, this directory must exist and is own
To start, run

```bash
docker-compose -f ./server/docker-compose.yml up
````
docker-compose -f ./docker/docker-compose.yml up
```

To force rebuild node modules after installing new packages

```bash
docker-compose -f ./server/docker-compose.yml up --build -V
docker-compose -f ./docker/docker-compose.yml up --build -V
```

The server will be running at `http://your-ip:2283` through `Nginx`
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
95 changes: 95 additions & 0 deletions docker/docker-compose.gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
version: "3.8"

services:
immich_server:
image: immich-server-dev:1.0.0
build:
context: ../server
target: development
dockerfile: ../server/Dockerfile
command: npm run start:dev
expose:
- "3000"
volumes:
- ../server:/usr/src/app
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- /usr/src/app/node_modules
env_file:
- .env
depends_on:
- redis
- database
networks:
- immich_network

redis:
container_name: immich_redis
image: redis:6.2
networks:
- immich_network

database:
container_name: immich_postgres
image: postgres:14
env_file:
- .env
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
PG_DATA: /var/lib/postgresql/data
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- 5432:5432
networks:
- immich_network

nginx:
container_name: proxy_nginx
image: nginx:latest
volumes:
- ./settings/nginx-conf:/etc/nginx/conf.d
ports:
- 2283:80
- 2284:443
logging:
driver: none
networks:
- immich_network
depends_on:
- immich_server

immich_tf_fastapi:
container_name: immich_tf_fastapi
image: tensor_flow_fastapi:1.0.0
restart: always
command: uvicorn app.main:app --proxy-headers --host 0.0.0.0 --port 8000 --reload
build:
context: ../machine_learning
target: gpu
dockerfile: ../machine_learning/Dockerfile
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
volumes:
- ../machine_learning/app:/code/app
- ${UPLOAD_LOCATION}:/code/app/upload
ports:
- 2285:8000
expose:
- "8000"
depends_on:
- database
networks:
- immich_network


networks:
immich_network:
volumes:
pgdata:
41 changes: 31 additions & 10 deletions server/docker-compose.yml → docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: '3.8'

version: "3.8"

services:
immich_server:
image: immich-server-dev:1.0.0
build:
context: .
context: ../server
target: development
dockerfile: ./Dockerfile
command: npm run start:dev
expose:
dockerfile: ../server/Dockerfile
entrypoint: ["/bin/sh", "./entrypoint.sh"]
# command: npm run start:dev
expose:
- "3000"
volumes:
- .:/usr/src/app
- ../server:/usr/src/app
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- /usr/src/app/node_modules
env_file:
Expand All @@ -27,7 +27,7 @@ services:
container_name: immich_redis
image: redis:6.2
networks:
- immich_network
- immich_network

database:
container_name: immich_postgres
Expand All @@ -44,7 +44,7 @@ services:
ports:
- 5432:5432
networks:
- immich_network
- immich_network

nginx:
container_name: proxy_nginx
Expand All @@ -61,7 +61,28 @@ services:
depends_on:
- immich_server

immich_tf_fastapi:
container_name: immich_tf_fastapi
image: tensor_flow_fastapi:1.0.0
restart: always
command: uvicorn app.main:app --proxy-headers --host 0.0.0.0 --port 8000 --reload
build:
context: ../machine_learning
target: cpu
dockerfile: ../machine_learning/Dockerfile
volumes:
- ../machine_learning/app:/code/app
- ${UPLOAD_LOCATION}:/code/app/upload
ports:
- 2285:8000
expose:
- "8000"
depends_on:
- database
networks:
- immich_network

networks:
immich_network:
volumes:
pgdata:
pgdata:
35 changes: 35 additions & 0 deletions docker/settings/nginx-conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

# events {
# worker_connections 1000;
# }

server {

client_max_body_size 50000M;

listen 80;

location / {
proxy_buffering off;
proxy_buffer_size 16k;
proxy_busy_buffers_size 24k;
proxy_buffers 64 4k;
proxy_force_ranges on;

proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;

proxy_pass http://immich_server:3000;
}
}
1 change: 1 addition & 0 deletions machine_learning/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
devenv/
2 changes: 2 additions & 0 deletions machine_learning/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
app/__pycache__
/devenv
22 changes: 22 additions & 0 deletions machine_learning/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## GPU Build
FROM tensorflow/tensorflow:latest-gpu as gpu

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY ./app /code/app


## CPU BUILD
FROM python:3.8 as cpu

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY ./app /code/app
17 changes: 17 additions & 0 deletions machine_learning/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
fastapi = "<0.69.0,>=0.68.0"
pydantic = "<2.0.0,>=1.8.0"
uvicorn = "<0.16.0,>=0.15.0"
tensorflow = "~=2.8.0"
numpy = "==1.22.2"
pillow = "==9.0.1"

[dev-packages]

[requires]
python_version = "3.8"
Loading