Skip to content

Commit

Permalink
Merge pull request #139 from Abhiifour/improved-loading
Browse files Browse the repository at this point in the history
enhanced loading page
  • Loading branch information
Pranav0-0Aggarwal authored Dec 27, 2024
2 parents d4791e7 + 644a031 commit a1780ee
Show file tree
Hide file tree
Showing 22 changed files with 721 additions and 696 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ body:
label: "Record"
options:
- label: "I agree to follow this project's Code of Conduct"
required: true
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ body:
options:
- label: "I agree to follow this project's Code of Conduct"
required: true
- label: "I want to work on this issue"
- label: "I want to work on this issue"
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ body:
options:
- label: "I agree to follow this project's Code of Conduct"
required: true
- label: "I want to work on this issue"
- label: "I want to work on this issue"
22 changes: 22 additions & 0 deletions docs/backend/backend_python/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

The API calls to PictoPy are done via HTTP requests since we are hosting our backend on a Flask server. This was done to ensure low coupling between the frontend and the backend.
Follow this [Link](https://www.postman.com/cryosat-explorer-62744145/workspace/pictopy/overview) to get example request and response.

## Table of Contents

1. [Albums](#albums)
2. [Image](#image)
3. [Face Recognition and Tagging](#face-recognition-and-tagging)
Expand All @@ -12,6 +14,7 @@ Follow this [Link](https://www.postman.com/cryosat-explorer-62744145/workspace/p
We briefly discuss the endpoints related to albums, all of these fall under the `/albums` route

### Create Album

- **Endpoint**: `POST /albums/create-album`
- **Description**: Creates a new album with the given name and optional description.
- **Request Format**:
Expand All @@ -24,6 +27,7 @@ We briefly discuss the endpoints related to albums, all of these fall under the
- **Response**: Message confirming album creation.

### Delete Album

- **Endpoint**: `DELETE /albums/delete-album`
- **Description**: Deletes an existing album by name.
- **Request Format**:
Expand All @@ -35,6 +39,7 @@ We briefly discuss the endpoints related to albums, all of these fall under the
- **Response**: Message confirming album deletion.

### Add Multiple Images to Album

- **Endpoint**: `POST /albums/add-multiple-to-album`
- **Description**: Adds multiple images to an existing album.
- **Request Format**:
Expand All @@ -47,6 +52,7 @@ We briefly discuss the endpoints related to albums, all of these fall under the
- **Response**: Message confirming images were added to the album.

### Remove Image from Album

- **Endpoint**: `DELETE /albums/remove-from-album`
- **Description**: Removes a single image from an album.
- **Request Format**:
Expand All @@ -59,12 +65,14 @@ We briefly discuss the endpoints related to albums, all of these fall under the
- **Response**: Message confirming image removal from the album.

### View Album Photos

- **Endpoint**: `GET /albums/view-album`
- **Description**: Retrieves all photos in a specified album.
- **Query Parameters**: `album_name` (string)
- **Response**: JSON object containing album name and list of photos.

### Edit Album Description

- **Endpoint**: `PUT /albums/edit-album-description`
- **Description**: Updates the description of an existing album.
- **Request Format**:
Expand All @@ -77,18 +85,23 @@ We briefly discuss the endpoints related to albums, all of these fall under the
- **Response**: Message confirming album description update.

### View All Albums

- **Endpoint**: `GET /albums/view-all`
- **Description**: Retrieves a list of all albums.
- **Response**: JSON object containing a list of all albums.

## Image

We briefly discuss the endpoints related to images, all of these fall under the `/images` route

### Get All Images

- **Endpoint**: `GET /images/all-images`
- **Description**: Retrieves a list of all image files in the system.
- **Response**: JSON object containing a list of image file paths.

### Add Multiple Images

- **Endpoint**: `POST /images/images`
- **Description**: Adds multiple images to the system and processes them in the background.
- **Request Format**:
Expand All @@ -100,6 +113,7 @@ We briefly discuss the endpoints related to images, all of these fall under the
- **Response**: Message indicating that images are being processed.

### Delete Image

- **Endpoint**: `DELETE /images/delete-image`
- **Description**: Deletes a single image from the system.
- **Request Format**:
Expand All @@ -111,17 +125,20 @@ We briefly discuss the endpoints related to images, all of these fall under the
- **Response**: Message confirming image deletion.

### Get All Image Objects

- **Endpoint**: `GET /images/all-image-objects`
- **Description**: Retrieves all images and their associated object classes.
- **Response**: JSON object mapping image paths to their object classes.

### Get Class IDs

- **Endpoint**: `GET /images/class-ids`
- **Description**: Retrieves the object classes for a specific image.
- **Query Parameters**: `path` (string) - full path to the image
- **Response**: JSON object containing the classes detected in the image.

### Add Folder

- **Endpoint**: `POST /images/add-folder`
- **Description**: Adds all images from a specified folder to the system and processes them in the background.
- **Request Format**:
Expand All @@ -133,18 +150,23 @@ We briefly discuss the endpoints related to images, all of these fall under the
- **Response**: Message indicating the number of images being processed from the folder.

## Face Recognition and Tagging

We briefly discuss the endpoints related to face tagging and recognition, all of these fall under the `/tag` route

### Face Matching

- **Endpoint**: `GET /tag/match`
- **Description**: Finds similar faces across all images in the database.
- **Response**: JSON object containing pairs of similar images and their similarity scores.

### Face Clusters

- **Endpoint**: `GET /tag/clusters`
- **Description**: Retrieves clusters of similar faces across all images.
- **Response**: JSON object containing clusters of images with similar faces.

### Related Images

- **Endpoint**: `GET /tag/related-images`
- **Description**: Finds images with faces related to the face in the given image.
- **Query Parameters**: `path` (string) - full path to the image
Expand Down
58 changes: 29 additions & 29 deletions docs/backend/backend_python/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
PictoPy uses several SQLite databases to manage various aspects of the application. This document provides an overview of each database, its structure, and its primary operations.

!!! note "Database Engine"
All databases in PictoPy use SQLite, a lightweight, serverless database engine.
All databases in PictoPy use SQLite, a lightweight, serverless database engine.

## Album Database

Expand All @@ -15,19 +15,19 @@ The database path is defined in the configuration file as `ALBUM_DATABASE_PATH`.

### Table Structure

| Column Name | Data Type | Constraints | Description |
|-------------|-----------|-------------|-------------|
| album_name | TEXT | PRIMARY KEY | Unique name of the album |
| image_ids | TEXT | | JSON-encoded list of image IDs |
| description | TEXT | | Album description |
| date_created | TIMESTAMP | DEFAULT CURRENT_TIMESTAMP | Creation date of the album |
| Column Name | Data Type | Constraints | Description |
| ------------ | --------- | ------------------------- | ------------------------------ |
| album_name | TEXT | PRIMARY KEY | Unique name of the album |
| image_ids | TEXT | | JSON-encoded list of image IDs |
| description | TEXT | | Album description |
| date_created | TIMESTAMP | DEFAULT CURRENT_TIMESTAMP | Creation date of the album |

### Functionality

The `albums.py` file contains functions for managing photo albums. It allows for creating and deleting albums, adding and removing photos from albums, retrieving album photos, editing album descriptions, and getting all albums.

!!! tip "JSON Encoding"
The `image_ids` field uses JSON encoding to store lists in a TEXT field.
The `image_ids` field uses JSON encoding to store lists in a TEXT field.

## Faces Database

Expand All @@ -37,18 +37,18 @@ The database path is defined in the configuration file as `FACES_DATABASE_PATH`.

### Table Structure

| Column Name | Data Type | Constraints | Description |
|-------------|-----------|-------------|-------------|
| id | INTEGER | PRIMARY KEY AUTOINCREMENT | Unique identifier for each face entry |
| image_id | INTEGER | FOREIGN KEY | References image_id_mapping(id) |
| embeddings | TEXT | | JSON-encoded face embeddings |
| Column Name | Data Type | Constraints | Description |
| ----------- | --------- | ------------------------- | ------------------------------------- |
| id | INTEGER | PRIMARY KEY AUTOINCREMENT | Unique identifier for each face entry |
| image_id | INTEGER | FOREIGN KEY | References image_id_mapping(id) |
| embeddings | TEXT | | JSON-encoded face embeddings |

### Functionality

The `faces.py` file manages face embeddings for images. It provides functionality for inserting and retrieving face embeddings, getting all face embeddings, deleting face embeddings for an image, and cleaning up orphaned face embeddings.

!!! warning "Referential Integrity"
The `image_id` column maintains referential integrity with the Images database.
The `image_id` column maintains referential integrity with the Images database.

## Images Database

Expand All @@ -60,25 +60,25 @@ The database path is defined in the configuration file as `IMAGES_DATABASE_PATH`

#### 1. image_id_mapping

| Column Name | Data Type | Constraints | Description |
|-------------|-----------|-------------|-------------|
| id | INTEGER | PRIMARY KEY AUTOINCREMENT | Unique identifier for each image |
| path | TEXT | UNIQUE | Absolute path to the image file |
| Column Name | Data Type | Constraints | Description |
| ----------- | --------- | ------------------------- | -------------------------------- |
| id | INTEGER | PRIMARY KEY AUTOINCREMENT | Unique identifier for each image |
| path | TEXT | UNIQUE | Absolute path to the image file |

#### 2. images

| Column Name | Data Type | Constraints | Description |
|-------------|-----------|-------------|-------------|
| id | INTEGER | PRIMARY KEY, FOREIGN KEY | References image_id_mapping(id) |
| class_ids | TEXT | | JSON-encoded class IDs |
| metadata | TEXT | | JSON-encoded metadata |
| Column Name | Data Type | Constraints | Description |
| ----------- | --------- | ------------------------ | ------------------------------- |
| id | INTEGER | PRIMARY KEY, FOREIGN KEY | References image_id_mapping(id) |
| class_ids | TEXT | | JSON-encoded class IDs |
| metadata | TEXT | | JSON-encoded metadata |

### Functionality

The `images.py` file manages image information, including paths, object classes, and metadata. It provides functions for inserting and deleting images, retrieving image paths and IDs, getting object classes for an image, and checking if an image is in the database.

!!! info "Path Handling"
The system uses absolute paths for image files to ensure consistency across different operations.
The system uses absolute paths for image files to ensure consistency across different operations.

## YOLO Mappings Database

Expand All @@ -88,10 +88,10 @@ The database path is defined in the configuration file as `MAPPINGS_DATABASE_PAT

### Table Structure

| Column Name | Data Type | Constraints | Description |
|-------------|-----------|-------------|-------------|
| class_id | INTEGER | PRIMARY KEY | YOLO class identifier |
| name | TEXT | NOT NULL | Human-readable class name |
| Column Name | Data Type | Constraints | Description |
| ----------- | --------- | ----------- | ------------------------- |
| class_id | INTEGER | PRIMARY KEY | YOLO class identifier |
| name | TEXT | NOT NULL | Human-readable class name |

### Functionality

Expand All @@ -106,4 +106,4 @@ The databases in PictoPy interact with each other in the following ways:
3. The Images database uses class IDs that correspond to the YOLO Mappings database for object recognition.

!!! example "Cross-Database Operation"
When adding a photo to an album, the system first checks if the image exists in the Images database, then adds its ID to the album in the Albums database.
When adding a photo to an album, the system first checks if the image exists in the Images database, then adds its ID to the album in the Albums database.
Loading

0 comments on commit a1780ee

Please sign in to comment.