{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/when-pigs-fly-contextual-reasoning-in","title":"When Pigs Fly: Contextual Reasoning in Synthetic and Natural Scenes","arxiv_id":"2104.02215","date":"2021-04-06","proceeding":"ICCV 2021 10","authors":["Philipp Bomatter","Mengmi Zhang","Dimitar Karev","Spandan Madan","Claire Tseng","Gabriel Kreiman"],"abstract":"Context is of fundamental importance to both human and machine vision; e.g., an object in the air is more likely to be an airplane than a pig. The rich notion of context incorporates several aspects including physics rules, statistical co-occurrences, and relative object sizes, among others. While previous work has focused on crowd-sourced out-of-context photographs from the web to study scene context, controlling the nature and extent of contextual violations has been a daunting task. Here we introduce a diverse, synthetic Out-of-Context Dataset (OCD) with fine-grained control over scene context. By leveraging a 3D simulation engine, we systematically control the gravity, object co-occurrences and relative sizes across 36 object categories in a virtual household environment. We conducted a series of experiments to gain insights into the impact of contextual cues on both human and machine vision using OCD. We conducted psychophysics experiments to establish a human benchmark for out-of-context recognition, and then compared it with state-of-the-art computer vision models to quantify the gap between the two. We propose a context-aware recognition transformer model, fusing object and contextual information via multi-head attention. Our model captures useful information for contextual reasoning, enabling human-level performance and better robustness in out-of-context conditions compared to baseline models across OCD and other out-of-context datasets. All source code and data are publicly available at https://github.com/kreimanlab/WhenPigsFlyContext","url_abs":"https://arxiv.org/abs/2104.02215v2","url_pdf":"https://arxiv.org/pdf/2104.02215v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"when-pigs-fly-contextual-reasoning-in","repo_url":"https://github.com/kreimanlab/WhenPigsFlyContext","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"object","task_name":"Object"}],"methods":[],"datasets_introduced":[{"slug":"ocd","name":"OCD","full_name":"Out-of-Context Dataset"}],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2104.02215","atlas_url":"https://app.syntology.ai/?focus=2104.02215","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2104.02215"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/kreimanlab/WhenPigsFlyContext","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":3,"unverified":3},"by_repo_kind":{"official":{"samples":6,"ran":3,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"721d8ac52576ca7f","entry":"build_uncertainty_gate","repo":"kreimanlab/WhenPigsFlyContext","repo_kind":"official","path":"core/model.py","file_url":"https://github.com/kreimanlab/WhenPigsFlyContext/blob/HEAD/core/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"721d8ac52576ca7f"}},{"code_sha256_prefix":"b3ca8a1b900d75f3","entry":"cuboid","repo":"kreimanlab/WhenPigsFlyContext","repo_kind":"official","path":"unity/display_graph.py","file_url":"https://github.com/kreimanlab/WhenPigsFlyContext/blob/HEAD/unity/display_graph.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b3ca8a1b900d75f3"}},{"code_sha256_prefix":"2e2a843780e52b94","entry":"display_grid_img","repo":"kreimanlab/WhenPigsFlyContext","repo_kind":"official","path":"unity/MMutils.py","file_url":"https://github.com/kreimanlab/WhenPigsFlyContext/blob/HEAD/unity/MMutils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2e2a843780e52b94"}},{"code_sha256_prefix":"799ad751135e3b25","entry":"display_scene_modalities","repo":"kreimanlab/WhenPigsFlyContext","repo_kind":"official","path":"unity/MMutils.py","file_url":"https://github.com/kreimanlab/WhenPigsFlyContext/blob/HEAD/unity/MMutils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"799ad751135e3b25"}},{"code_sha256_prefix":"8e3413a872edc331","entry":"find_nodes","repo":"kreimanlab/WhenPigsFlyContext","repo_kind":"official","path":"unity/MMutils.py","file_url":"https://github.com/kreimanlab/WhenPigsFlyContext/blob/HEAD/unity/MMutils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8e3413a872edc331"}},{"code_sha256_prefix":"fc264d88eed3353e","entry":"get_xyz_mouse_click","repo":"kreimanlab/WhenPigsFlyContext","repo_kind":"official","path":"unity/display_graph.py","file_url":"https://github.com/kreimanlab/WhenPigsFlyContext/blob/HEAD/unity/display_graph.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fc264d88eed3353e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}