Skip to content

Assignment 1: Image Classifier Tutorial#143

Merged
ColtonPayne merged 6 commits into
mainfrom
bruno-branch
May 11, 2026
Merged

Assignment 1: Image Classifier Tutorial#143
ColtonPayne merged 6 commits into
mainfrom
bruno-branch

Conversation

@BAF1927

@BAF1927 BAF1927 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Changes

  • examples/image_classifier_ex.py — standalone example script
  • docs/source/tutorials/image_classifier_reasoning.rst — tutorial documentation page
  • examples/images/ — sample images for flamingos and eagles

Summary

Builds an image-classification reasoning example with fish, sharks, flamingos, and eagles.
Uses a pretrained ViT model to classify local images, converts predictions into PyReason facts, and runs rule-based inference to derive:

  • is_fish, is_shark, is_flamingo, is_eagle, is_bird
  • can_fly from is_bird
  • likes_to_eat edges (shark/flamingo -> fish)
    Also includes a full tutorial page explaining the pipeline (image -> classifier -> facts -> reasoning -> output), expected terminal output, and warnings about using only labels that exist in the model.

Terminal Output

Screenshot 2026-04-24 at 11 59 20 p m Screenshot 2026-04-25 at 12 00 16 a m Screenshot 2026-04-25 at 12 00 41 a m Screenshot 2026-04-25 at 12 01 28 a m

1. Worked in the rst file to put a site with tutorial
2. Added New Species such as flamingos and eagles to tutorial
3. Added some comments for full visualization of table to tutorial
@@ -0,0 +1,337 @@
Image Classifier to PyReason Tutorial

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the tutorial to index.rst so it shows up in the docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the following line at the index.rst
./image_classifier_reasoning.rst
I must admit, for some reason it is not showing up when going to the other tutorial pages, but it does appear in the general one.

This produces explanations for which rule fired, on which node/edge, and why.


Expected Output (Full Run + Analysis)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't show the full classifier output here - highlight the important steps for each image.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to divide the traces per animals and make a general explanation that when an animal is identified it is set to [1,1]

Image

Fixed Point iterations: 3
NODE RULE TRACE:

Time Fixed-Point-Operation Node Label Old Bound New Bound Occurred Due To Consistent Triggered By Inconsistency Message Clause-1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just pasting the full trace, highlight key groundings from each timestep and explain why they were grounded.

@BAF1927 BAF1927 May 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to put what happens on each pass trough and a summarized run of the trace by covering the tables with ...

Image

NODE RULE TRACE:

Time Fixed-Point-Operation Node Label Old Bound New Bound Occurred Due To Consistent Triggered By Inconsistency Message Clause-1
0 0 0 fish_1 goldfish [0.0,1.0] [1.0,1.0] fish_1-goldfish-fact True Fact None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the full trace in examples/csv_outputs

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Csv files have been created based on a run.

BAF1927 and others added 5 commits May 4, 2026 20:47
1. Improved reading documentation
2. Divided the output more effectively
3. Created Csv Files with output
4. Added the tutorial to the index
1. Removed additional traces
2. Added images of expected output
3. Added source of LLM into tutorial

@ColtonPayne ColtonPayne left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ColtonPayne ColtonPayne merged commit 09a4f99 into main May 11, 2026
3 checks passed
@ColtonPayne ColtonPayne deleted the bruno-branch branch May 11, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants