Skip to content

Add optional .pth weight loading before training#77

Open
jddark62 wants to merge 1 commit into
manikyabard:masterfrom
jddark62:bounty-14-load-existing-pth
Open

Add optional .pth weight loading before training#77
jddark62 wants to merge 1 commit into
manikyabard:masterfrom
jddark62:bounty-14-load-existing-pth

Conversation

@jddark62

@jddark62 jddark62 commented Jun 5, 2026

Copy link
Copy Markdown

Closes #14.

Summary

  • Added save.load_existing, save.load_dir, and save.load_name to the default project config.
  • Added backend support to load an existing fastai .pth weights file immediately after the task learner is created in /generate.
  • Accepts either a .pth file name or a file stem for load_name.
  • Documented the resume-from-weights flow in the README.

Verification

  • git diff --check
  • python3 -m py_compile worker/app/app.py
  • Parsed app/src/assets/data.json, data/response.json, data/response_temp.json, and data/response_temp2.json with Node.js.
  • Applied the patch cleanly to a fresh clone and re-ran syntax/JSON/content checks.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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, and save.load_name config fields to the default JSON payloads.
  • Implemented backend support in worker/app/app.py to optionally call Learner.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 thread worker/app/app.py
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)
Comment thread README.md
### 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.
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.

Add option to load from .pth in the beginning.

2 participants