diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 5a9bfe0..70976d2 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Install dependencies run: | diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 009e24e..4c9b9b5 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Install dependencies run: | diff --git a/.github/workflows/pylint-auto.yml b/.github/workflows/pylint-auto.yml index 370c316..c99c1a1 100644 --- a/.github/workflows/pylint-auto.yml +++ b/.github/workflows/pylint-auto.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Install dependencies run: | diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index 1b1233d..5321509 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Install dependencies run: | @@ -49,7 +49,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Download package artifacts uses: actions/download-artifact@v2 @@ -62,16 +62,29 @@ jobs: sudo apt-get install libsox-dev sudo apt-get install sox -y sudo apt install ffmpeg -y + python -m venv .venv + source .venv/bin/activate python -m pip install --upgrade pip python -m pip install *.whl - - name: Run unit tests + - name: Download Sample Data run: | + source .venv/bin/activate python src/common/download_data.py + + - name: Run unit tests + run: | + source .venv/bin/activate python src/api/mimasa/manage.py test face_detection + - name: Run Audio & Video Translations + run: | + source .venv/bin/activate + python src/main.py + - name: Generate Coverage Reports run: | + source .venv/bin/activate coverage run src/api/mimasa/manage.py test face_detection coverage html diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a276121..bd9f539 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Get tag run: | @@ -51,7 +51,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.10.x + python-version: 3.11.x - name: Get tag run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e4d17a..8245874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,51 +1,58 @@ -# Change Log - -All notable changes to this package will be documented in this file. -This package adheres to [Semantic Versioning](http://semver.org/). - -## 1.1.2 release - -### Bug Fixes - -* Fix transaltion module import error -* Add support to download mimasa sample data -* Improve setup envrionment script - -## 1.1.1 release - -### Bug Fixes - -* Fix dependency issues -* Add pre-commit config to fix linting issues - -## 1.1.0 release - -### Features - -* Add Django App for Mimasa to perform translations -* Add asynchronous functionality to detect faces and separate audio -* Add translation units for mimasa app and video, audio interfaces -* Improve face detection performance with asynchronous approaches added - -### Documentation - -* Document expected features and stories -* Document performance results - -### Bug Fixes - -* Fix labeler workflow for PRs -* Added tests results for performance of face detection & audio separation -* Prepare a demo video for Mimasa Django App - -## 1.0.0 release - -### Features - -* Initial implementation of Mimasa App with FaceDetector component implemented -* Implement AudioSeparator component with NUSSL Separator - -### Documentation - -* Design documentation is added including components relationship, mimasa-state behavior and sequence diagrams -* Prepared the concept of Mimasa Application +# Change Log + +All notable changes to this package will be documented in this file. +This package adheres to [Semantic Versioning](http://semver.org/). + +## 1.1.3 release + +### Bug Fixes + +* Improve the stability of the GHA with testing Auido & Video Translations +* Fix project name in setup script + +## 1.1.2 release + +### Bug Fixes + +* Fix transaltion module import error +* Add support to download mimasa sample data +* Improve setup envrionment script + +## 1.1.1 release + +### Bug Fixes + +* Fix dependency issues +* Add pre-commit config to fix linting issues + +## 1.1.0 release + +### Features + +* Add Django App for Mimasa to perform translations +* Add asynchronous functionality to detect faces and separate audio +* Add translation units for mimasa app and video, audio interfaces +* Improve face detection performance with asynchronous approaches added + +### Documentation + +* Document expected features and stories +* Document performance results + +### Bug Fixes + +* Fix labeler workflow for PRs +* Added tests results for performance of face detection & audio separation +* Prepare a demo video for Mimasa Django App + +## 1.0.0 release + +### Features + +* Initial implementation of Mimasa App with FaceDetector component implemented +* Implement AudioSeparator component with NUSSL Separator + +### Documentation + +* Design documentation is added including components relationship, mimasa-state behavior and sequence diagrams +* Prepared the concept of Mimasa Application diff --git a/README.md b/README.md index 57fb4d4..f8ed20b 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ For the latest updates and news regarding Mimasa, please follow the [Announcemen ### Prerequisites -- [Python 3.10.x](https://www.python.org/downloads/) +- [Python 3.11.x](https://www.python.org/downloads/) - [pip](https://pip.pypa.io/en/stable/installation/) - Update the [settings](https://github.com/developers-cosmos/Mimasa/blob/main/src/common/config.py) for the application @@ -96,7 +96,7 @@ The Django app for Mimasa is a web-based application that allows users to intera ### Prerequisites -- Python 3.10.x +- Python 3.11.x - pip - Django 4.x - Redis diff --git a/setup.py b/setup.py index 7c3838b..14c84d5 100644 --- a/setup.py +++ b/setup.py @@ -1,65 +1,65 @@ -#!/usr/bin/env python3 -""" -This module contains the setup script for installing the package. -""" -import os -import subprocess - -from setuptools import find_packages, setup -from setuptools.command.install import install - -DESCRIPTION = """ -Mimasa is a real-time multilingual face translator application that takes a video input, -detects the facial patterns and speech of the person, translates the speech to another language -and changes the facial expression of the person to match the output language. The final output -is a video with the translated speech and modified facial expression. -""" - - -class LintCommand(install): - """Custom command to run linting on package installation.""" - - def run(self): - """Run linter.""" - subprocess.call(["pylint", "src"]) - install.run(self) - - -with open("requirements.txt", encoding="utf-8") as f: - requirements = f.read().splitlines() - -os.environ["PYTHONPATH"] = os.path.join(os.getcwd(), "src") -author_list = ["Yellenki Ritheesh Baradwaj"] - -setup( - name="Mimasa", - version="1.1.2", - author=", ".join(author_list), - author_email="ritheeshbaradwaj@gmail.com", - description="A Real-time Multilingual Face Translator", - long_description=DESCRIPTION, - url="https://github.com/developers-cosmos/Mimasa", - packages=find_packages(), - install_requires=requirements, - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - python_requires=">=3.6", - scripts=["src/main.py"], - include_package_data=True, - package_data={ - "": ["*.txt"], - }, - entry_points={ - "console_scripts": [ - "mimasa = src.main:main", - ], - }, - env={"PYTHONPATH": os.path.abspath(os.path.join(os.path.dirname(__file__), "src"))}, - # NOTE: Disbale the following lines to avoid lint checking - cmdclass={ - "install": LintCommand, - }, -) +#!/usr/bin/env python3 +""" +This module contains the setup script for installing the package. +""" +import os +import subprocess + +from setuptools import find_packages, setup +from setuptools.command.install import install + +DESCRIPTION = """ +Mimasa is a real-time multilingual face translator application that takes a video input, +detects the facial patterns and speech of the person, translates the speech to another language +and changes the facial expression of the person to match the output language. The final output +is a video with the translated speech and modified facial expression. +""" + + +class LintCommand(install): + """Custom command to run linting on package installation.""" + + def run(self): + """Run linter.""" + subprocess.call(["pylint", "src"]) + install.run(self) + + +with open("requirements.txt", encoding="utf-8") as f: + requirements = f.read().splitlines() + +os.environ["PYTHONPATH"] = os.path.join(os.getcwd(), "src") +author_list = ["Yellenki Ritheesh Baradwaj"] + +setup( + name="Mimasa", + version="1.1.3", + author=", ".join(author_list), + author_email="ritheeshbaradwaj@gmail.com", + description="A Real-time Multilingual Face Translator", + long_description=DESCRIPTION, + url="https://github.com/developers-cosmos/Mimasa", + packages=find_packages(), + install_requires=requirements, + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + python_requires=">=3.6", + scripts=["src/main.py"], + include_package_data=True, + package_data={ + "": ["*.txt"], + }, + entry_points={ + "console_scripts": [ + "mimasa = src.main:main", + ], + }, + env={"PYTHONPATH": os.path.abspath(os.path.join(os.path.dirname(__file__), "src"))}, + # NOTE: Disbale the following lines to avoid lint checking + cmdclass={ + "install": LintCommand, + }, +) diff --git a/src/api/mimasa/translation/urls.py b/src/api/mimasa/translation/urls.py index f31c015..f6fd408 100644 --- a/src/api/mimasa/translation/urls.py +++ b/src/api/mimasa/translation/urls.py @@ -1,7 +1,6 @@ from django.urls import path -from .views import (MimasaCreateView, download_translation, get_task_status, - translation, update_mimasa_instance) +from .views import MimasaCreateView, download_translation, get_task_status, translation, update_mimasa_instance urlpatterns = [ path("", MimasaCreateView.as_view(), name="mimasa_application"), diff --git a/src/audioseparator/mask_inference.py b/src/audioseparator/mask_inference.py index af35cba..64eea80 100644 --- a/src/audioseparator/mask_inference.py +++ b/src/audioseparator/mask_inference.py @@ -4,8 +4,7 @@ """ import nussl -from nussl.ml.networks.modules import (AmplitudeToDB, BatchNorm, Embedding, - RecurrentStack) +from nussl.ml.networks.modules import AmplitudeToDB, BatchNorm, Embedding, RecurrentStack from torch import nn diff --git a/src/common/cleanup_data.py b/src/common/cleanup_data.py index 670f548..3e69037 100644 --- a/src/common/cleanup_data.py +++ b/src/common/cleanup_data.py @@ -8,15 +8,7 @@ import os from src.common.config import Config - - -def remove_file(file_path: str): - """ - Remove a file if it exists - """ - - if os.path.exists(file_path): - os.remove(file_path) +from src.utils.utils import remove_file def cleanup_models(): @@ -38,9 +30,9 @@ def cleanup_audios(): audio_path = Config.AUDIO_INPUT_PATH audios = { - "input.wav" : "187smy0j5CCGhQlf-AheLz2pvIP-3DR3c", - "input1.wav" : "1ExFxlJkUmYCtgMkWdOiDP_y3daSiB1PL", - "input2.wav" : "14HJ7OxsfUpU2taNKrX-ehC6AonfjaxVi", + "input.wav": "187smy0j5CCGhQlf-AheLz2pvIP-3DR3c", + "input1.wav": "1ExFxlJkUmYCtgMkWdOiDP_y3daSiB1PL", + "input2.wav": "14HJ7OxsfUpU2taNKrX-ehC6AonfjaxVi", } for filename, _ in audios.items(): @@ -54,8 +46,8 @@ def cleanup_videos(): video_path = Config.VIDEO_INPUT_PATH videos = { - "input1.mp4" : "1T-fmD9JffWdp51FS_inQuzu_FCOlVvI9", - "input2.mp4" : "1mlfGQmkhJc5jxY5RPde6eA0TZeCPTo6R", + "input1.mp4": "1T-fmD9JffWdp51FS_inQuzu_FCOlVvI9", + "input2.mp4": "1mlfGQmkhJc5jxY5RPde6eA0TZeCPTo6R", } for filename, _ in videos.items(): @@ -69,10 +61,10 @@ def cleanup_translations(): translation_path = Config.TRANSLATION_INPUT_PATH videos = { - "movie1.mp4" : "14CC9hKnrOw4jSsUxUD35GWKYnQHShxKe", - "movie2.mp4" : "1PQ3t9_Uulu_GjYorv8Iur48af6fwKSyQ", - "movie3.mp4" : "1x2yrExwi9FYxMBk-O8OEvMPZA73BeTbP", - "movie4.mp4" : "1zIFR8rXwuOnF6tXkN08h7PTsqrM7WgAj", + "movie1.mp4": "14CC9hKnrOw4jSsUxUD35GWKYnQHShxKe", + "movie2.mp4": "1PQ3t9_Uulu_GjYorv8Iur48af6fwKSyQ", + "movie3.mp4": "1x2yrExwi9FYxMBk-O8OEvMPZA73BeTbP", + "movie4.mp4": "1zIFR8rXwuOnF6tXkN08h7PTsqrM7WgAj", } for filename, _ in videos.items(): diff --git a/src/common/download_data.py b/src/common/download_data.py index 0436209..2c67886 100644 --- a/src/common/download_data.py +++ b/src/common/download_data.py @@ -8,6 +8,7 @@ from src.utils import utils from src.common.config import Config + def download_models(): """ Function to download models @@ -17,7 +18,9 @@ def download_models(): for model in models: if model == "nussl": output_path = Config.MODEL_NUSSL_PATH - utils.download_file_from_google_drive("https://drive.google.com/uc?id=1CKwaqBj55b83qoZbg66gaUsewnQh4k8g", output_path) + utils.download_file_from_google_drive( + "https://drive.google.com/uc?id=1CKwaqBj55b83qoZbg66gaUsewnQh4k8g", output_path + ) def download_audios(): @@ -27,9 +30,9 @@ def download_audios(): audio_path = Config.AUDIO_INPUT_PATH audios = { - "input.wav" : "187smy0j5CCGhQlf-AheLz2pvIP-3DR3c", - "input1.wav" : "1ExFxlJkUmYCtgMkWdOiDP_y3daSiB1PL", - "input2.wav" : "14HJ7OxsfUpU2taNKrX-ehC6AonfjaxVi", + "input.wav": "187smy0j5CCGhQlf-AheLz2pvIP-3DR3c", + "input1.wav": "1ExFxlJkUmYCtgMkWdOiDP_y3daSiB1PL", + "input2.wav": "14HJ7OxsfUpU2taNKrX-ehC6AonfjaxVi", } for filename, url_id in audios.items(): @@ -43,8 +46,8 @@ def download_videos(): video_path = Config.VIDEO_INPUT_PATH videos = { - "input1.mp4" : "1T-fmD9JffWdp51FS_inQuzu_FCOlVvI9", - "input2.mp4" : "1mlfGQmkhJc5jxY5RPde6eA0TZeCPTo6R", + "input1.mp4": "1T-fmD9JffWdp51FS_inQuzu_FCOlVvI9", + "input2.mp4": "1mlfGQmkhJc5jxY5RPde6eA0TZeCPTo6R", } for filename, url_id in videos.items(): @@ -58,10 +61,10 @@ def download_translations(): translation_path = Config.TRANSLATION_INPUT_PATH videos = { - "movie1.mp4" : "14CC9hKnrOw4jSsUxUD35GWKYnQHShxKe", - "movie2.mp4" : "1PQ3t9_Uulu_GjYorv8Iur48af6fwKSyQ", - "movie3.mp4" : "1x2yrExwi9FYxMBk-O8OEvMPZA73BeTbP", - "movie4.mp4" : "1zIFR8rXwuOnF6tXkN08h7PTsqrM7WgAj", + "movie1.mp4": "14CC9hKnrOw4jSsUxUD35GWKYnQHShxKe", + "movie2.mp4": "1PQ3t9_Uulu_GjYorv8Iur48af6fwKSyQ", + "movie3.mp4": "1x2yrExwi9FYxMBk-O8OEvMPZA73BeTbP", + "movie4.mp4": "1zIFR8rXwuOnF6tXkN08h7PTsqrM7WgAj", } for filename, url_id in videos.items(): diff --git a/src/facedetector/utils.py b/src/facedetector/utils.py index 483df98..2d47b0b 100644 --- a/src/facedetector/utils.py +++ b/src/facedetector/utils.py @@ -7,10 +7,14 @@ from src.common.libraries import * from src.common.logger import Logger -from src.facedetector import (async_io_and_cpu_face_detector, - async_task_face_detector, - concurrent_futures_face_detector, mtcnn, ssd, - viola_jones) +from src.facedetector import ( + async_io_and_cpu_face_detector, + async_task_face_detector, + concurrent_futures_face_detector, + mtcnn, + ssd, + viola_jones, +) from src.utils.utils import get_current_time """ diff --git a/src/utils/utils.py b/src/utils/utils.py index 0a1c5a6..0dec045 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -127,3 +127,15 @@ def download_file_from_google_drive(url, output_path): download_file_msg = "An error occured: " + str(ex) logger.error(download_file_msg) raise ex + + +def remove_file(file_path: str): + logger = Logger(name="CleanUp") + logger.add_file_handler("cleanup.log") + """ + Remove a file if it exists + """ + + if os.path.exists(file_path): + os.remove(file_path) + logger.info(f"Successfully removed file: {file_path}") diff --git a/tools/setup_env.sh b/tools/setup_env.sh index a95e67a..803fe5d 100755 --- a/tools/setup_env.sh +++ b/tools/setup_env.sh @@ -34,3 +34,4 @@ fi # Python package installation python -m pip install --upgrade pip pip install -r requirements.txt +python setup.py install