Skip to content

awesomething/classifire

Repository files navigation

What this project does

  • Goal: Classify images as either logo or nologo and make it easy to search a folder for items like “t‑shirts with/without a logo”.
  • Artifacts: A trained Keras .h5 model in models/ and two user interfaces: a chat-style CLI and a Streamlit web app.

Where the trained model is used

  • The .h5 model is loaded by model_utils.load_trained_model().
  • Both chat_cli.py and streamlit_app.py import load_trained_model from model_utils.py and use it for inference.

Key components

  • model_utils.py

    • load_trained_model(path=None): loads the trained .h5 from models/imageclassify.h5 (default) or a path you pass.
    • predict_image(model, image_path): returns {image_path, logo_probability, predicted_label}.
    • predict_folder(model, folder, keyword_filter=None, limit=None, recursive=True): scans a folder, predicts for each image.
    • Note: The model trained in the notebook outputs a value where higher means “nologo”. The utilities invert that so logo_probability reflects the chance of a logo.
  • chat_cli.py

    • Loads the model and runs an interactive prompt (chat-style) to search folders for items like “show me t-shirts with logo”.
    • Parses phrases such as "with logo" and "without a logo".
    • Scans data/ and logos/ by default (or a custom folder via --scan).
  • streamlit_app.py

    • Web UI to upload a single image or scan a folder and visualize predictions.
    • Sidebar inputs let you choose model path and scan folder; results are shown with thumbnails.

How it works end-to-end

  1. Your .h5 model is discovered at models/imageclassify.h5 by default.
  2. Images are loaded and resized to the model’s input size, normalized to [0,1].
  3. The model’s output is post-processed so that logo_probability is in [0,1] and predicted_label is either logo or nologo.
  4. CLI/App filter results by label and keyword, and sort by confidence.

Quickstart

  • Install deps:

    • pip install -r requirements.txt
  • Chat CLI:

    • python chat_cli.py --model models/imageclassify.h5 --scan data
    • Example queries:
      • show me t-shirts with logo
      • show me t-shirts without a logo
      • top 10 caps with logo
  • Streamlit app:

    • streamlit run streamlit_app.py
    • Use the sidebar to set model path and scan folder; use tabs to upload or scan.

Configuration and customization

  • Model path: pass --model to CLI or set the sidebar field in the app.
  • Scan path: pass --scan to CLI or set the sidebar field in the app.
  • Label mapping: If you retrain a model with different output ordering, adjust _postprocess_output() in model_utils.py.

Troubleshooting

  • "No matching images found":
    • Ensure the keyword matches filenames or parent folder names (e.g., use t-shirt, tshirts, or tee).
    • Check the scan folder contains images with extensions like .jpg, .png.
    • Try removing the keyword to see if images are detected at all.
  • Predictions look inverted (logo vs nologo): Revisit _postprocess_output() and the logic from your training notebook.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published