{"id":19849511,"url":"https://github.com/filipspl/tf_consensus_score","last_synced_at":"2026-06-11T11:31:10.754Z","repository":{"id":196563668,"uuid":"695576722","full_name":"filipsPL/tf_consensus_score","owner":"filipsPL","description":"Calculating consensus scores from multiple TensorFlow Lite classificaitons","archived":false,"fork":false,"pushed_at":"2023-09-25T17:19:59.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T23:10:15.673Z","etag":null,"topics":["consensus","python3","tensorflow-lite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filipsPL.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}},"created_at":"2023-09-23T15:36:20.000Z","updated_at":"2023-09-25T17:35:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2d526df-61ff-4404-9306-6fbde8b7aba3","html_url":"https://github.com/filipsPL/tf_consensus_score","commit_stats":null,"previous_names":["filipspl/tf_consensus_score"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/filipsPL/tf_consensus_score","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipsPL%2Ftf_consensus_score","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipsPL%2Ftf_consensus_score/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipsPL%2Ftf_consensus_score/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipsPL%2Ftf_consensus_score/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filipsPL","download_url":"https://codeload.github.com/filipsPL/tf_consensus_score/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filipsPL%2Ftf_consensus_score/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34197393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["consensus","python3","tensorflow-lite"],"created_at":"2024-11-12T13:21:24.135Z","updated_at":"2026-06-11T11:31:10.734Z","avatar_url":"https://github.com/filipsPL.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tf_consensus_score\n\nThis module contains a collection of functions for calculating consensus scores from multiple TensorFlow Lite classificaitons.\n\n```text\n┌─────────────┐\n│             │\n│  Image      │       ┌─────────────────────────────────┐      ┌──────────────────────┐\n│             ├──────►│                                 │      │                      │\n└─────────────┘       │                                 │      │                      │\n                      │                                 │      │ Output:              │\n┌─────────────┐       │      tf_consensus_score.py      ├─────►│                      │\n│tfl model 1  ├──────►│                                 │      │ cat 0.9255041480     │\n├─────────────┤       │                                 │      │                      │\n│tfl model 2  │       │                                 │      │                      │\n├─────────────┤       └─────────────────────────────────┘      └──────────────────────┘\n│tfl model n  │\n└─────────────┘\n```\n\n\nUsage:\n\n```python\nimport cv2\nfrom tf_consensus_score import *\n\n# Initialize a dictionary for local model files\nmodel_files = {}\n\n# Add model files to the dictionary\nmodel_files = [\n    \"animals1.tflite\",\n    \"animals2.tflite\"\n]\n\n# Define the path where models are located\nmodels_path = \"models/\"\n\n# Read the image the cv2 way\nimage = cv2.imread(\"cat.jpg\", cv2.IMREAD_COLOR)\n\n# Calc consensus score and return the highest scored class\ncategory_name, score = calc_consensus(image, model_files, models_path)\nprint(category_name, score)\n\n# cat 0.9255041480\n```\n\n## Installation\n\nJust download `tf_consensus_score.py` and put in the program directory.\n\n## Functions\n\n### `calc_probabilities_for_image(image, local_model_file)`\n\nCalculate probabilities for a given image using a specific model file.\n\n#### Arguments\n\n- `image`: The input image to be classified.\n- `local_model_file`: The path to the local TensorFlow Lite model file.\n\n#### Returns\n\nA list of classification categories and their corresponding probabilities.\n\n### `calculate_consensus_scores(ProbabilitiesForImage)`\n\nCalculate consensus scores based on a list of probabilities for multiple models.\n\n#### Arguments\n\n- `ProbabilitiesForImage`: A list of probabilities for each model.\n\n#### Returns\n\nA list of consensus scores for each category based on the input probabilities.\n\n### `return_best_consensus_category(consensus)`\n\nFind the category with the highest consensus score.\n\n#### Arguments\n\n- `consensus`: A list of consensus scores for each category.\n\n#### Returns\n\nA tuple containing the best category name and its score.\n\n### `calc_probabilities_for_all_models(image, local_model_files, models_path)`\n\nCalculate probabilities for all models in a list.\n\n#### Arguments\n\n- `image`: The input image to be classified.\n- `models_path`: The path where model files are located.\n- `local_model_files`: A list of model file names for a specific category.\n\n#### Returns\n\nA list of probabilities for each model in the input list.\n\n### `calc_consensus(image, local_model_files, models_path)`\n\nCalculate the consensus category and score for a given image.\n\n#### Arguments\n\n- `image`: The input image to be classified.\n- `models_path`: The path where model files are located.\n- `local_model_files`: A list of model file names for a specific category.\n\n#### Returns\n\nA tuple containing the consensus category name and its score based on the input probabilities.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilipspl%2Ftf_consensus_score","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilipspl%2Ftf_consensus_score","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilipspl%2Ftf_consensus_score/lists"}