Compare commits
No commits in common. "290772dfa2b50d9409a410f8cf210378983a9c93" and "e886e8af7e9b0756b1ec9e16f3a2a09f666efc8f" have entirely different histories.
290772dfa2
...
e886e8af7e
@ -1,6 +0,0 @@
|
|||||||
*.md
|
|
||||||
/venv
|
|
||||||
.git
|
|
||||||
__pycache__
|
|
||||||
.pytest_cache
|
|
||||||
/tests
|
|
@ -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"]
|
|
@ -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
After Width: | Height: | Size: 204 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
@ -1,5 +1,3 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
from jproperties import Properties
|
from jproperties import Properties
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -12,11 +10,9 @@ from jproperties import Properties
|
|||||||
def translate(to_translate, lang):
|
def translate(to_translate, lang):
|
||||||
try:
|
try:
|
||||||
config = Properties()
|
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
|
# 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')
|
config.load(config_file, encoding='UTF-8')
|
||||||
|
|
||||||
# Translate labels for given to_translate dictionary
|
# Translate labels for given to_translate dictionary
|
||||||
|
2
main.py
@ -103,4 +103,4 @@ def upload_file():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0')
|
app.run(debug=True)
|
||||||
|
@ -3,6 +3,3 @@ numpy==1.26.3
|
|||||||
pillow==10.2.0
|
pillow==10.2.0
|
||||||
keras==2.15.0
|
keras==2.15.0
|
||||||
jproperties==2.1.1
|
jproperties==2.1.1
|
||||||
tensorflow==2.15.0
|
|
||||||
werkzeug==3.0.1
|
|
||||||
pytest==7.4.4
|
|
@ -1,24 +0,0 @@
|
|||||||
@echo off
|
|
||||||
chcp 65001 >nul
|
|
||||||
|
|
||||||
docker -v >nul 2>&1
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo [31mDocker is not installed.[0m
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
docker info >nul 2>&1
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo [31mDocker engine is not running.[0m
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
cd ../docker
|
|
||||||
echo [32mBuilding docker image...[0m
|
|
||||||
docker compose build cat-detection
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo [31mBuilding cdocker imagew failed.[0m
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
echo [32mThe image was built successfully.[0m
|
|
@ -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"
|
|
@ -1,14 +0,0 @@
|
|||||||
@echo off
|
|
||||||
echo [32mRunning unit tests.[0m
|
|
||||||
|
|
||||||
set PYTHONPATH=%CD%;%PYTHONPATH%
|
|
||||||
|
|
||||||
cd %~dp0
|
|
||||||
pytest ../tests
|
|
||||||
|
|
||||||
if %ERRORLEVEL% equ 0 (
|
|
||||||
echo [32mTests passed successfully.[0m
|
|
||||||
) else (
|
|
||||||
Tests failed.
|
|
||||||
echo [31mTests failed.[0m
|
|
||||||
)
|
|
@ -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 [31mStarting docker container failed.[0m
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
@ -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
|
|
Before Width: | Height: | Size: 360 KiB |
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 216 KiB |
Before Width: | Height: | Size: 326 KiB |
Before Width: | Height: | Size: 221 KiB |
Before Width: | Height: | Size: 281 KiB |
Before Width: | Height: | Size: 469 KiB |
Before Width: | Height: | Size: 255 KiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 345 KiB |
@ -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
|
|
@ -1,3 +1,5 @@
|
|||||||
|
import imghdr
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Validation method.
|
Validation method.
|
||||||
If everything fine then returns empty list.
|
If everything fine then returns empty list.
|
||||||
|