Add optional .pth weight loading before training#77
Open
jddark62 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a configuration-driven “resume from weights” capability to the DashAI backend so an existing fastai .pth can be loaded immediately after learner creation (before training), and updates the example/config JSON plus README to document the flow.
Changes:
- Added
save.load_existing,save.load_dir, andsave.load_nameconfig fields to the default JSON payloads. - Implemented backend support in
worker/app/app.pyto optionally callLearner.load()right after the learner is created in/generate. - Documented the resume-from-weights behavior in
README.md.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| worker/app/app.py | Adds a helper to optionally load .pth weights after learner creation in /generate. |
| README.md | Documents how to resume from an existing fastai weights file via the new config fields. |
| data/response.json | Extends the default request payload schema with the new load-related save.* keys. |
| data/response_temp.json | Same as above for the temp payload. |
| data/response_temp2.json | Same as above for the temp payload. |
| app/src/assets/data.json | Updates the frontend asset/default payload with the new load-related save.* keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+99
to
+106
| load_dir = Path(load_dir) | ||
| load_file = Path(load_name) | ||
| if load_file.suffix == '.pth': | ||
| load_file = load_file.with_suffix('') | ||
|
|
||
| learner.model_dir = load_dir | ||
| print(f'Loading existing model weights from {load_dir / (str(load_file) + ".pth")}') | ||
| return learner.load(load_file) |
| ### Step 3: Selecting the model. | ||
| You then have to choose what architecture they want your model to have. DashAI provides architectures that have achieved state-of-the-art results in the task defined, but you may use any model built using PyTorch layers. | ||
|
|
||
| To resume from an existing fastai `.pth` weights file before training, set `save.load_existing` to `true`, set `save.load_dir` to the directory that contains the file, and set `save.load_name` to the file name or file stem. DashAI will create the learner for the selected task and then load those weights before the training step begins. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14.
Summary
save.load_existing,save.load_dir, andsave.load_nameto the default project config..pthweights file immediately after the task learner is created in/generate..pthfile name or a file stem forload_name.Verification
git diff --checkpython3 -m py_compile worker/app/app.pyapp/src/assets/data.json,data/response.json,data/response_temp.json, anddata/response_temp2.jsonwith Node.js.I could not run the full DashAI app build or ML workflow in this workspace because npm/yarn/pnpm/npx and the full Python fastai runtime are not installed here.