{"id":15913122,"url":"https://github.com/x-tabdeveloping/visual-analytics-assignment1","last_synced_at":"2025-04-03T03:16:35.586Z","repository":{"id":224065656,"uuid":"762289579","full_name":"x-tabdeveloping/visual-analytics-assignment1","owner":"x-tabdeveloping","description":"First assignment for visual analytics course.","archived":false,"fork":false,"pushed_at":"2024-05-13T16:31:23.000Z","size":470,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T17:14:40.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/x-tabdeveloping.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}},"created_at":"2024-02-23T13:23:25.000Z","updated_at":"2024-05-13T16:31:27.000Z","dependencies_parsed_at":"2024-05-12T12:26:36.333Z","dependency_job_id":"09691c75-7b6b-411d-9276-393f03cd8a70","html_url":"https://github.com/x-tabdeveloping/visual-analytics-assignment1","commit_stats":null,"previous_names":["x-tabdeveloping/visual-analytics-assignment1"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-tabdeveloping%2Fvisual-analytics-assignment1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-tabdeveloping%2Fvisual-analytics-assignment1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-tabdeveloping%2Fvisual-analytics-assignment1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-tabdeveloping%2Fvisual-analytics-assignment1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x-tabdeveloping","download_url":"https://codeload.github.com/x-tabdeveloping/visual-analytics-assignment1/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927844,"owners_count":20856198,"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","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":[],"created_at":"2024-10-06T16:23:12.219Z","updated_at":"2025-04-03T03:16:35.460Z","avatar_url":"https://github.com/x-tabdeveloping.png","language":"Python","readme":"# visual-analytics-assignment1\nFirst assignment for visual analytics course.\nThis assignment is oriented at image retrieval in the [17 Category Flower Dataset](https://www.robots.ox.ac.uk/~vgg/data/flowers/17/)\n\n## Setup\n\nAfter downloading the data all jpg files should be arranged in one folder.\nIn the examples I will use the following folder structure:\n\n```\n - data/\n    - jpg/\n        - files.txt\n        - image_0001.jpg\n        ...\n```\n\n \u003e Beware!! The data directory in the repo is only added for demonstration puposes and for including the example images in the README.\n\nThe code ignore the `files.txt` file and scans the directory for all images.\nThis choice was made so that the code is easily reusable in non-indexed image datasets.\n\nEach image is assumed to have a particular ID, this is the stem of the image path.\nE.g. for the file `image_0001.jpg` its ID would be `\"image_0001\"`.\nThese IDs will be later used for specifying which image to base the search on.\n\n\nTo run the code first install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## Usage\n\nThe repository contains code for a command line interface that can search in the dataset based on one user-specified image.\nThe CLI can use multiple distance metrics and types of latent representations to achieve this.\n\n### Color Histograms\n\nTo do image retrieval based on minmax normalized color histograms, run the following:\n\n```bash\npython3 src/hist_search.py data/jpg/image_0001.jpg -o \"out/hist\"\n```\n\nThis will put a CSV file with the images closest to the target by Chi Square histogram distance in the `out/hist` folder.\n\n```\n - out/\n    - hist/\n        - image_0001.csv\n```\n\nThese are the results I got:\n\n||Image|Distance|\n|-|-|-|\n|0|\u003cimg src=\"data/jpg/image_0001.jpg\" alt=\"image_0001\" width=\"200px\"\u003e|0.0|\n|1|\u003cimg src=\"data/jpg/image_0773.jpg\" alt=\"image_0773\" width=\"200px\"\u003e|190.13992491162105|\n|2|\u003cimg src=\"data/jpg/image_1316.jpg\" alt=\"image_1316\" width=\"200px\"\u003e|190.2249241130487|\n|3|\u003cimg src=\"data/jpg/image_0740.jpg\" alt=\"image_0740\" width=\"200px\"\u003e|190.62783760197846|\n|4|\u003cimg src=\"data/jpg/image_1078.jpg\" alt=\"image_1078\" width=\"200px\"\u003e|191.69055452774253|\n|5|\u003cimg src=\"data/jpg/image_0319.jpg\" alt=\"image_0319\" width=\"200px\"\u003e|191.8753821638015|\n\nAs we can see many of the images barely resemble the original, and I would deem the performance of this method not satisfactory.\nThe problem likely lies in the histograms being too sparse (`256*256*256` bins) and the exact same colors rarely occur in two different images.\nIncreasing the size of the bins would likely yield much better results.\n\n### VGG16 \n\nTo use VGG16 image embeddings and cosine distance to search in the images run this command:\n\n```bash\npython3 src/embedding_search.py data/jpg/image_0001.jpg -o \"out/vgg16\"\n```\n\nThis will put a CSV file with the images closest to the target cosine distance in the `out/vgg16` folder.\n\n```\n - out/\n    - vgg16/\n        - image_0001.csv\n```\n\n| |Image|Distance|\n|-|-|-|\n|0|\u003cimg src=\"data/jpg/image_0001.jpg\" alt=\"image_0001\" width=\"200px\"\u003e|1.369352364832821e-08|\n|1|\u003cimg src=\"data/jpg/image_0049.jpg\" alt=\"image_0049\" width=\"200px\"\u003e|0.00986799891034007|\n|2|\u003cimg src=\"data/jpg/image_0072.jpg\" alt=\"image_0072\" width=\"200px\"\u003e|0.010539749814202692|\n|3|\u003cimg src=\"data/jpg/image_1050.jpg\" alt=\"image_1050\" width=\"200px\"\u003e|0.010623027922563977|\n|4|\u003cimg src=\"data/jpg/image_0018.jpg\" alt=\"image_0018\" width=\"200px\"\u003e|0.011068601062943717|\n|5|\u003cimg src=\"data/jpg/image_0020.jpg\" alt=\"image_0020\" width=\"200px\"\u003e|0.011395322683994236|\n\n### Parameters\n\n| Argument                | Description                                                                                  | Type    | Default           |\n|-------------------------|----------------------------------------------------------------------------------------------|---------|-------------------|\n| `query_image_path`              | Path to query image.                                                                    |         | -                 |\n| `-h`, `--help`          | Show this help message and exit.                                                             |         |                   |\n| `-i IMAGES_PATH`,\u003cbr\u003e`--images_path IMAGES_PATH` | Path to the source directory containing images.                                           | str     | `\"data/jpg\"`                 |\n| `-o OUT_PATH`,\u003cbr\u003e`--out_path OUT_PATH` | Path to the output directory to save results.                                                | str     | `\"out\"`                 |\n| `-k TOP_K`,\u003cbr\u003e`--top_k TOP_K` | Top K similar images to retrieve.                                                             | int     | 5                 |\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-tabdeveloping%2Fvisual-analytics-assignment1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-tabdeveloping%2Fvisual-analytics-assignment1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-tabdeveloping%2Fvisual-analytics-assignment1/lists"}