Skip to content

refactor!: add static factories for remaining models#937

Open
chmjkb wants to merge 8 commits intomainfrom
@chmjkb/static-factories-refactor
Open

refactor!: add static factories for remaining models#937
chmjkb wants to merge 8 commits intomainfrom
@chmjkb/static-factories-refactor

Conversation

@chmjkb
Copy link
Collaborator

@chmjkb chmjkb commented Mar 5, 2026

Description

This PR refactors the existing codebase to match what has been recently done with object detection & semantic segmentation. Namely, it changes the model initialization flow from new Module() -> module.load() to a single, static factory, for example: fromModelName(modelName)

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Other (chores, tests, code style improvements etc.)

Tested on

  • iOS
  • Android

Testing instructions

Screenshots

Related issues

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional notes

chmjkb and others added 6 commits March 5, 2026 12:44
- Remove abstract load() from BaseModule (enables clean factory subclasses)
- Remove no-op load() overrides from BaseLabeledModule and VisionLabeledModule
- Add deps parameter to useModuleFactory, relax Config generic constraint
- Update useObjectDetection and useSemanticSegmentation to pass explicit deps
- Convert ClassificationModule: private constructor + static fromModelName()
- Migrate useClassification from useModule to useModuleFactory

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd telemetry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chmjkb chmjkb marked this pull request as ready for review March 5, 2026 14:06
@chmjkb chmjkb marked this pull request as draft March 5, 2026 14:19
@chmjkb chmjkb marked this pull request as ready for review March 6, 2026 08:12
Copy link
Contributor

@NorbertKlockiewicz NorbertKlockiewicz left a comment

Choose a reason for hiding this comment

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

LGTM!

@benITo47
Copy link
Contributor

benITo47 commented Mar 6, 2026

Code looks good - didn't run it though.

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.

Migrate existing model implementations to use factories instead of legacy flow

3 participants