{"id":18237492,"url":"https://github.com/philiptitus/gamma","last_synced_at":"2026-02-08T19:02:36.760Z","repository":{"id":258861446,"uuid":"859319978","full_name":"philiptitus/Gamma","owner":"philiptitus","description":"Machine Learnig API for facial, tone analysis and so much more. For The comprehensive API documentation check out: https://documenter.getpostman.com/view/31401198/2sAY4yegFh","archived":false,"fork":false,"pushed_at":"2024-11-13T18:49:19.000Z","size":1684,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-15T13:27:46.109Z","etag":null,"topics":["ai","aws","aws-ec2","aws-s3","django","docker","docker-compose","machine-learning","opencv","python","pytorch","tensorflow"],"latest_commit_sha":null,"homepage":"https://gammaai.duckdns.org/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philiptitus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-18T13:16:19.000Z","updated_at":"2024-11-18T14:34:57.000Z","dependencies_parsed_at":"2025-04-11T11:41:33.740Z","dependency_job_id":"dbed51c4-ad21-48f4-86d2-82c5ee3e75f5","html_url":"https://github.com/philiptitus/Gamma","commit_stats":null,"previous_names":["philiptitus/gamma"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/philiptitus/Gamma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philiptitus%2FGamma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philiptitus%2FGamma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philiptitus%2FGamma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philiptitus%2FGamma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philiptitus","download_url":"https://codeload.github.com/philiptitus/Gamma/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philiptitus%2FGamma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29240131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T18:06:38.086Z","status":"ssl_error","status_checked_at":"2026-02-08T18:06:09.124Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","aws","aws-ec2","aws-s3","django","docker","docker-compose","machine-learning","opencv","python","pytorch","tensorflow"],"created_at":"2024-11-05T02:04:46.614Z","updated_at":"2026-02-08T19:02:36.744Z","avatar_url":"https://github.com/philiptitus.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gamma API\n\nGamma API is a Django-based RESTful API designed to analyze emotions from video files. It utilizes `cv2` and the `DeepFace` library to perform facial emotion detection on video frames. Emotions are analyzed using TensorFlow for efficient GPU-based computation, with the results stored and shared with users via email notifications.\n\n## Core Features\n\n1. **Video Emotion Analysis**: Processes video frames to detect and analyze emotions.\n2. **Multi-Threading**: Uses threading to improve performance and handle multiple requests concurrently.\n3. **AWS S3 Integration**: Temporarily stores video files in an S3 bucket before analysis.\n4. **Email Notifications**: Sends analysis results to users via email.\n5. **Token-Based Session Tracking**: Assigns unique tokens for each session to track individual video analysis tasks.\n\n## Technologies Used\n\n### 1. Python Libraries and Frameworks\n- **Django**: The web framework that powers Gamma API, enabling efficient handling of HTTP requests and database interactions.\n- **Django REST Framework (DRF)**: Used to create the API endpoints for uploading videos and retrieving results.\n- **OpenCV (cv2)**: Processes video frames, resizes them, and performs basic pre-processing.\n- **DeepFace**: Performs emotion detection on individual frames, analyzing faces with the MTCNN backend.\n- **TensorFlow**: Configured to use GPU memory efficiently for accelerated deep learning tasks.\n- **Boto3**: AWS SDK for Python, handling interactions with AWS S3 for video storage.\n\n### 2. Multi-Threading and Queue Management\n- **ThreadPoolExecutor**: Allows concurrent frame analysis using multiple threads.\n- **Threading and Queue**: A worker thread is used to handle video processing tasks in a queue, ensuring efficient task execution.\n\n### 3. Amazon Web Services (AWS)\n- **Amazon S3**: Stores video files temporarily, enabling streaming for analysis without relying on local storage.\n- **AWS S3 Credentials**: Access to S3 is managed through AWS credentials set in Django's settings file.\n\n### 4. Email Notifications\n- **Django Email System**: Sends email reports to users upon analysis completion.\n- **HTML Templates**: Custom email templates are used to display results, including dominant emotion and calmness percentage.\n\n## Installation\n\n### Prerequisites\n- Python 3.x\n- Virtual environment tool (e.g., `venv`)\n- AWS account with an S3 bucket\n- Django and Django REST Framework\n- TensorFlow-compatible GPU (optional but recommended for performance)\n\n### Steps\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/philiptitus/Gamma-API.git\n   cd Gamma-API\n   ```\n\n2. **Create and activate a virtual environment**:\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n   ```\n\n3. **Install dependencies**:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n4. **Set up environment variables**:\n   - Configure AWS credentials in your Django settings:\n     ```python\n     AWS_ACCESS_KEY_ID = '\u003cYOUR_AWS_ACCESS_KEY\u003e'\n     AWS_SECRET_ACCESS_KEY = '\u003cYOUR_AWS_SECRET_KEY\u003e'\n     AWS_STORAGE_BUCKET_NAME = '\u003cYOUR_BUCKET_NAME\u003e'\n     AWS_S3_REGION_NAME = '\u003cYOUR_REGION\u003e'\n     AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'\n     ```\n   - Set up email credentials for notification delivery:\n     ```python\n     EMAIL_HOST = 'smtp.your_email_host.com'\n     EMAIL_PORT = 587\n     EMAIL_HOST_USER = 'your_email@example.com'\n     EMAIL_HOST_PASSWORD = 'your_password'\n     EMAIL_USE_TLS = True\n     ```\n\n5. **Run Migrations**:\n   ```bash\n   python manage.py migrate\n   ```\n\n6. **Start the Django server**:\n   ```bash\n   python manage.py runserver\n   ```\n\n### API Endpoints\n\n#### Upload and Analyze Video\n- **Endpoint**: `/analyze-video/`\n- **Method**: POST\n- **Description**: Accepts a video file and email, then initiates analysis and returns a token for tracking the session.\n\n**Request Body**:\n- `video`: The video file to be analyzed.\n- `email`: Email address to send results to.\n\n**Response**:\n```json\n{\n  \"token\": \"\u003cunique_session_token\u003e\"\n}\n```\n\n### Example Usage\n\n1. **Uploading a Video for Analysis**:\n   ```bash\n   curl -X POST -F \"video=@path/to/video.mp4\" -F \"email=user@example.com\" http://localhost:8000/analyze-video/\n   ```\n   Response:\n   ```json\n   {\n       \"token\": \"123e4567-e89b-12d3-a456-426614174000\"\n   }\n   ```\n\n### Technical Breakdown\n\n1. **Video Analysis Flow**:\n   - Videos are uploaded to an S3 bucket.\n   - Frames are extracted and resized.\n   - Emotion analysis is performed on every 20th frame (configurable).\n   - Emotion results are stored and processed, generating a calmness score and dominant emotion.\n\n2. **Session Tracking**:\n   - Each video analysis session is assigned a unique token, stored in the database with the analysis results.\n\n3. **Multi-Threaded Emotion Analysis**:\n   - Uses `ThreadPoolExecutor` for concurrent frame analysis.\n   - Thread queue ensures stable task processing, improving performance under high loads.\n\n4. **Email Notification**:\n   - Results are formatted and sent as HTML emails, including the dominant emotion and calmness score.\n   - Email templates are stored in the Django project for easy customization.\n\n## Contributing\n\nContributions are welcome! If you'd like to improve the functionality or add new features, please open an issue or submit a pull request.\n\n## License\n\nThis project is open-source and licensed under the MIT License.\n\n---\n\n\u0026copy; 2024 Philip Titus\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphiliptitus%2Fgamma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphiliptitus%2Fgamma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphiliptitus%2Fgamma/lists"}