pixaris.feedback_handlers package
Submodules
pixaris.feedback_handlers.base module
- class pixaris.feedback_handlers.base.FeedbackHandler[source]
Bases:
object
- abstractmethod create_feedback_iteration(local_image_directory: str, project: str, feedback_iteration: str, date_suffix: str = None, dataset: str = None, experiment_name: str = None)[source]
Creates a feedback iteration, which involves persisting the creation to a feedback table as well as save the corresponding images.
- Parameters:
images_directory (str) – Path to local directory containing images to upload
project (str) – Name of the project
feedback_iteration (str) – Name of the feedback iteration
date_suffix (str) – Date suffix for versioning. Will be set automatically to today if not provided.
dataset (str) – Name of the evaluation dataset (optional)
experiment_name (str) – Name of the experiment (optional)
- feedback_df = Empty DataFrame Columns: [] Index: []
- feedback_iteration_choices = []
- get_feedback_per_image(feedback_iteration, image_name) dict [source]
Get feedback for a specific image.
- Parameters:
feedback_iteration (str) – Name of the feedback iteration
image_name (str) – Name of the image
- Returns:
Dictionary with feedback information for the image with the following format: {“likes”: int, “dislikes”: int, “comments_liked”: list, “comments_disliked”: list}
- Return type:
dict
- load_all_feedback_iteration_info_for_project(project: str) None [source]
Retrieves feedback data for a project. Adds paths for location of images in local directory to the dataframe. Saves the resulting df to self.feedback_df. Saves the list of feedback iterations to self.feedback_iteration_choices.
- Parameters:
project (str) – Name of the project
- abstractmethod load_images_for_feedback_iteration(feedback_iteration: str, sorting: str = 'image_name') list[str] [source]
Returns list of local image paths that belong to the feedback iteration. Optionally loads images.
- Parameters:
feedback_iteration (str) – Name of the feedback iteration
sorting (str) – Sorting option for the images. Can be “image_name”, “likes”, or “dislikes”. Default is “image_name”.
- Returns:
List of local image paths
- Return type:
list[str]
- abstractmethod load_projects_list() list[str] [source]
Returns the list of projects.
- Returns:
List of projects
- Return type:
list[str]
- abstractmethod write_single_feedback(feedback: dict[str, any]) None [source]
Writes feedback for one image to the feedback table.
- Parameters:
feedback – dict with feedback information. Dict is expected to have the following keys:
project: name of the project
feedback_iteration: name of the iteration
dataset: name of the evaluation set (optional)
image_name: name of the image
experiment_name: name of the experiment (optional)
feedback_indicator: string with feedback value (either “Like”, “Dislike”, or “Neither”)
comment: string with feedback comment (optional)
pixaris.feedback_handlers.gcp module
- class pixaris.feedback_handlers.gcp.GCPFeedbackHandler(gcp_project_id: str, gcp_bq_feedback_table: str, gcp_pixaris_bucket_name: str, local_feedback_directory: str = 'local_results')[source]
Bases:
FeedbackHandler
GCPFeedbackHandler is a class that handles feedback for Pixaris using Google Cloud Platform (GCP). Contains methods to start handle feedback iterations storing data in BigQuery and images in a GCP bucket. It also retrieves feedback data from the BigQuery table and downloads images from the GCP bucket to display them in the frontend.
- Parameters:
gcp_project_id (str) – GCP project ID
gcp_bq_feedback_table (str) – GCP BigQuery table for feedback
gcp_pixaris_bucket_name (str) – GCP bucket name for Pixaris
local_feedback_directory (str) – Local directory to store feedback images, default is “local_results”
- create_feedback_iteration(local_image_directory: str, project: str, feedback_iteration: str, date_suffix: str = None, dataset: str = None, experiment_name: str = None)[source]
Upload images to GCP bucket and persist initialisation of feedback iteration to BigQuery.
- Parameters:
images_directory (str) – Path to local directory containing images to upload
project (str) – Name of the project
feedback_iteration (str) – Name of the feedback iteration
date_suffix (str) – Date suffix for versioning. Will be set automatically to today if not provided.
dataset (str) – Name of the evaluation dataset (optional)
experiment_name (str) – Name of the experiment (optional)
- load_images_for_feedback_iteration(feedback_iteration: str, sorting: str = 'image_name') list[str] [source]
Downloads images for a feedback iteration from GCP bucket to local directory. Returns list of local image paths that belong to the feedback iteration.
- Parameters:
feedback_iteration (str) – Name of the feedback iteration
sorting (str) – Sorting option for the images. Can be “image_name”, “likes”, or “dislikes”. Default is “image_name”.
- Returns:
List of local image paths that belong to the feedback iteration.
- Return type:
list[str]
- load_projects_list() list[str] [source]
Retrieves list of projects from BigQuery table.
- Returns:
List of projects
- Return type:
list[str]
- write_single_feedback(feedback: dict) None [source]
Writes feedback for one image to BigQuery table.
- Parameters:
feedback – dict with feedback information. Dict is expected to have the following keys:
project: name of the project
feedback_iteration: name of the iteration
dataset: name of the evaluation set (optional)
image_name: name of the image
experiment_name: name of the experiment (optional)
feedback_indicator: string with feedback value (either “Like”, “Dislike”, or “Neither”)
comment: string with feedback comment (optional)
pixaris.feedback_handlers.local module
- class pixaris.feedback_handlers.local.LocalFeedbackHandler(project_feedback_dir: str = 'feedback_iterations', project_feedback_file: str = 'feedback_tracking.jsonl', local_feedback_directory: str = 'local_results')[source]
Bases:
FeedbackHandler
Local feedback handler for Pixaris. This class is used to handle feedback iterations locally. It allows for the creation of feedback iterations, writing feedback to local storage, and loading feedback data from local storage.
- Parameters:
project_feedback_dir (str) – Directory where feedback iterations are stored. Default is “feedback_iterations”.
project_feedback_file (str) – Name of the feedback file. Default is “feedback_tracking.jsonl”.
local_feedback_directory (str) – Local directory for storing feedback data. Default is “local_results”.
- create_feedback_iteration(local_image_directory: str, project: str, feedback_iteration: str, date_suffix: str = None, dataset: str = '', experiment_name: str = '')[source]
Saves images in experiment_directorey to a feedback_iteration folder. Puts initial entries into local feedback database.
- Parameters:
local_image_directory (str) – Path to the directory containing the images
project (str) – Name of the project
feedback_iteration (str) – Name of the feedback iteration
image_names (list[str]) – List of image names to use in the feedback iteration
dataset (str) – Name of the dataset (optional)
experiment_name (str) – Name of the experiment (optional)
- load_images_for_feedback_iteration(feedback_iteration: str, sorting: str = 'image_name') list[str] [source]
Returns list of local image paths that belong to the feedback iteration.
- Parameters:
feedback_iteration (str) – Name of the feedback iteration
sorting (str) – Sorting option for the images. Can be “image_name”, “likes”, or “dislikes”. Default is “image_name”.
- Returns:
List of local image paths
- Return type:
list[str]
- load_projects_list() list[str] [source]
Retrieves list of projects from local storage.
- Returns:
List of project names
- Return type:
list[str]
- write_single_feedback(feedback: dict) None [source]
Writes feedback for one image to local feedback storage.
- Parameters:
feedback – dict with feedback information. Dict is expected to have the following keys:
project: name of the project
feedback_iteration: name of the iteration
dataset: name of the evaluation set (optional)
image_name: name of the image
experiment_name: name of the experiment (optional)
feedback_indicator: string with feedback value (either “Like”, “Dislike”, or “Neither”)
comment: string with feedback comment (optional)