Compare commits

..

No commits in common. "290772dfa2b50d9409a410f8cf210378983a9c93" and "e886e8af7e9b0756b1ec9e16f3a2a09f666efc8f" have entirely different histories.

29 changed files with 5 additions and 141 deletions

View File

@ -1 +0,0 @@
Cat detection

View File

@ -1,6 +0,0 @@
*.md
/venv
.git
__pycache__
.pytest_cache
/tests

View File

@ -1,11 +0,0 @@
FROM python:3.11
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
CMD ["python", "main.py"]

View File

@ -1,10 +0,0 @@
version: '3.3'
services:
cat-detection:
image: cat-detection
build:
context: ../
dockerfile: ./docker/Dockerfile
ports:
- "5000:5000"

BIN
img/cat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -1,5 +1,3 @@
import os
from jproperties import Properties
"""
@ -12,11 +10,9 @@ from jproperties import Properties
def translate(to_translate, lang):
try:
config = Properties()
script_directory = os.path.dirname(os.path.abspath(__file__))
resources_path = os.path.join(script_directory, "./resources")
# Load properties file for given lang
with open(os.path.join(resources_path, f"./{lang}.properties"), 'rb') as config_file:
with open(f"resources/{lang}.properties", 'rb') as config_file:
config.load(config_file, encoding='UTF-8')
# Translate labels for given to_translate dictionary

View File

@ -103,4 +103,4 @@ def upload_file():
if __name__ == '__main__':
app.run(host='0.0.0.0')
app.run(debug=True)

View File

@ -3,6 +3,3 @@ numpy==1.26.3
pillow==10.2.0
keras==2.15.0
jproperties==2.1.1
tensorflow==2.15.0
werkzeug==3.0.1
pytest==7.4.4

View File

@ -1,24 +0,0 @@
@echo off
chcp 65001 >nul
docker -v >nul 2>&1
if %errorlevel% neq 0 (
echo Docker is not installed.
exit /b 1
)
docker info >nul 2>&1
if %errorlevel% neq 0 (
echo Docker engine is not running.
exit /b 1
)
cd ../docker
echo Building docker image...
docker compose build cat-detection
if %errorlevel% neq 0 (
echo Building cdocker imagew failed.
exit /b 1
)
echo The image was built successfully.

View File

@ -1,27 +0,0 @@
#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
docker -v > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "\033[31mDocker is not installed.\033[0m"
exit 1
fi
docker info > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "\033[31mDocker engine is not running.\033[0m"
exit 1
fi
cd ../docker
echo -e "\033[32mBuilding docker image...\033[0m"
docker-compose build cat-detection
if [ $? -ne 0 ]; then
echo -e "\033[31mBuilding docker image failed.\033[0m"
exit 1
fi
echo -e "\033[32mThe image was built successfully.\033[0m"

View File

@ -1,14 +0,0 @@
@echo off
echo Running unit tests.
set PYTHONPATH=%CD%;%PYTHONPATH%
cd %~dp0
pytest ../tests
if %ERRORLEVEL% equ 0 (
echo Tests passed successfully.
) else (
Tests failed.
echo Tests failed.
)

View File

@ -1,8 +0,0 @@
@echo off
chcp 65001 >nul
docker compose -f ../docker/docker-compose.yml up cat-detection -d
if %errorlevel% neq 0 (
echo Starting docker container failed.
exit /b 1
)

View File

@ -1,11 +0,0 @@
#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
docker-compose -f ../docker/docker-compose.yml up cat-detection -d
if [ $? -ne 0 ]; then
echo -e "\033[31mStarting docker container failed.\033[0m"
exit 1
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 KiB

View File

@ -1,19 +0,0 @@
import os
from werkzeug.datastructures import FileStorage
from main import app
def test_upload_file():
with app.test_client() as test_client:
script_directory = os.path.dirname(os.path.abspath(__file__))
image_path = os.path.join(script_directory, "./img/tiger_cat/cat1.jpg")
image = FileStorage(
stream=open(image_path, "rb"),
filename="cat1.jpg",
content_type="image/jpeg",
)
response = test_client.post('/api/v1/detect-cat', data={'image': image}, content_type='multipart/form-data')
assert response.status_code == 200

View File

@ -1,3 +1,5 @@
import imghdr
"""
Validation method.
If everything fine then returns empty list.