Skip to content

refactor!: add static factories for remaining models#937

Draft
chmjkb wants to merge 5 commits intomainfrom
@chmjkb/static-factories-refactor
Draft

refactor!: add static factories for remaining models#937
chmjkb wants to merge 5 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 5 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>
@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
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

1 participant