{"id":24936740,"url":"https://github.com/cestmerneil/logicvision","last_synced_at":"2025-09-02T10:36:39.714Z","repository":{"id":273758510,"uuid":"920784313","full_name":"CestMerNeil/LogicVision","owner":"CestMerNeil","description":"This project combines segmentation model and logic tensor network to realize the reasoning of object relationship in images and improve image content analysis through first-order logic formula and multi-layer perceptron network. ","archived":false,"fork":false,"pushed_at":"2025-03-31T13:13:16.000Z","size":50957,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T14:29:59.396Z","etag":null,"topics":["ltntorch","oneformer","visualgenome-dataset","yolo"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CestMerNeil.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-22T19:07:58.000Z","updated_at":"2025-03-31T13:13:19.000Z","dependencies_parsed_at":"2025-02-08T19:28:15.904Z","dependency_job_id":"48f243de-40e1-4c82-88f9-9f1e7cbdcb35","html_url":"https://github.com/CestMerNeil/LogicVision","commit_stats":null,"previous_names":["cestmerneil/logicvision"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/CestMerNeil/LogicVision","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CestMerNeil%2FLogicVision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CestMerNeil%2FLogicVision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CestMerNeil%2FLogicVision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CestMerNeil%2FLogicVision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CestMerNeil","download_url":"https://codeload.github.com/CestMerNeil/LogicVision/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CestMerNeil%2FLogicVision/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273271914,"owners_count":25075969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"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":["ltntorch","oneformer","visualgenome-dataset","yolo"],"created_at":"2025-02-02T16:57:06.844Z","updated_at":"2025-09-02T10:36:39.687Z","avatar_url":"https://github.com/CestMerNeil.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![English](https://cdn3.iconfinder.com/data/icons/142-mini-country-flags-16x16px/32/flag-usa2x.png)](/README.md)\n[![Français](https://cdn3.iconfinder.com/data/icons/142-mini-country-flags-16x16px/32/flag-france2x.png)](/README/README_fr_FR.md)\n[![中文](https://cdn3.iconfinder.com/data/icons/142-mini-country-flags-16x16px/32/flag-china2x.png)](/README/README_zh_CN.md)\n[![日本語](https://cdn3.iconfinder.com/data/icons/142-mini-country-flags-16x16px/32/flag-japan2x.png)](/README/README_ja_JP.md)\n\n# Understanding visual scenes using logistic tensor neural networks 🚀🤖\n\n[![Python 3.12](https://img.shields.io/badge/Python-3.12-blue?style=flat-square)](https://www.python.org)\n[![CUDA 12.4](https://img.shields.io/badge/CUDA-12.4-red?style=flat-square)](https://developer.nvidia.com/cuda-toolkit)\n[![LTNTorch](https://img.shields.io/badge/Project-LTNTorch-9cf?style=flat-square)](https://github.com/tommasocarraro/LTNtorch)\n[![Visual Genome](https://img.shields.io/badge/Data-Visual%20Genome-yellow?style=flat-square)](https://homes.cs.washington.edu/~ranjay/visualgenome/index.html)\n[![YOLO](https://img.shields.io/badge/Detection-YOLO-orange?style=flat-square)](https://github.com/ultralytics/ultralytics)\n[![OneFormer](https://img.shields.io/badge/Segmentation-OneFormer-brightgreen?style=flat-square)](https://github.com/SHI-Labs/OneFormer)\n\nThis project combines segmentation model and logic tensor network to realize the reasoning of object relationship in images and improve image content analysis through first-order logic formula and multi-layer perceptron network. ✨\n\n---\n\n## Overall architecture and module division\n![Overall Architecture](/README/images/Architecture.png)\n\n1. **✨ Image segmentation and feature extraction**: The YOLO-Seg model from [UltraLytics](https://docs.ultralytics.com) or the OneFormer model from [SHI-Labs](https://www.shi-labs.com) is used to segment and extract features from the input image. image for segmentation and feature extraction.\n2. **✨Goal relation detection**: using a logic tensor network from [LTNTorch](https://github.com/tommasocarraro/LTNtorch), each goal is converted into a logical predicate, which is then reasoned over by the logic tensor network.\n3. **✨Logical Relationship Training**: Logistic tensor networks were trained using relational data from the [Visual Genome](https://homes.cs.washington.edu/~ranjay/visualgenome/index.html) database.\n4. **✨ Output of reasoning results**: reads the relations found by the user using the form of a ternary and outputs the results of the reasoning.\n\n\n## Installation Guide\n\n### Training environment (Ubuntu 22.04)\n```bash\npip install -r requirements.train.txt\n```\n\n### Reasoning environment (macOS 15.3)\n```bash\npip install -r requirements.inference.txt\n```\n\nPre-trained models for YOLO and OneFormer are automatically downloaded when the program is run.\n\n## Guidelines for use\n\n### Example of training\n```Python\nfrom utils.Trainer import trainer\n\npredicate = [\"in\", \"on\", \"next to\"]\nfor pred in predicate:\n    print(f\"🚂 Training {pred} ...\")\n    trainer(\n        pos_predicate=pred,\n        neg_predicates=[p for p in predicate if p != pred],\n        epoches=50,\n        batch_size=32,\n        lr=1e-4\n    )\n```\n\n### Examples of inference\n```Python\nfrom utils.Inferencer import Inferencer\n\n# Initialize the inferencer\nanalyzer = Inferencer(\n    subj_class=\"person\",\n    obj_class=\"bicycle\",\n    predicate=\"near\"\n)\n\n# Perform inference on a single image\nresult = analyzer.inference_single(\"demo.jpg\")\nprint(f\"🔎 Get ：{result['relation']} (Confidence：{result['confidence']:.2f})\")\n\n# Perform inference on a folder of images\nanalyzer.process_folder(\"input_images/\")\n```\n\n# Dataset\nThe relationships and image metadata data from the [Visual Genome](https://homes.cs.washington.edu/~ranjay/visualgenome/index.html) database were used to extract image information and feature pair information.\n\n![Visual Genole Example](/README/images/Visual_Genome.png)\n\n\nThe project extracts data and target locations from relational data, and extracts image data to normalize the target locations.\n\n# Code Style and Documentation\nThis project uses the ```black``` and ```isort``` to automatically enforce a consistent code style. All code comments and documentation follow the [Google Python Style Guide](https://google.github.io/styleguide/) to maintain clarity and consistency.\n\n\nUse the following command to keep the code in the same format before submitting.\n```bash\nblack . \u0026\u0026 isort . \n```\n# Acknowledgements\nThis project is based on the [LTNTorch](https://github.com/tommasocarraro/LTNtorch) project and uses the [Visual Genome](https://homes.cs.washington.edu/~ranjay/visualgenome/api_beginners_tutorial.html) database for data extraction. The project uses the [YOLO](https://doc.ultralytics.com) and [OneFormer](https://www.shi-labs.com) models for object detection and segmentation.\n\n# License\nThis project is licensed under the GNU3.0 License - see the [LICENSE](/LICENSE) file for details.\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcestmerneil%2Flogicvision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcestmerneil%2Flogicvision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcestmerneil%2Flogicvision/lists"}