Skip to content

Fix app.py local model check to require config.json too - #1

Open
SID-6921 wants to merge 1 commit into
udgamlabs:mainfrom
SID-6921:fix/app-local-path-check
Open

SID-6921 wants to merge 1 commit into
udgamlabs:mainfrom
SID-6921:fix/app-local-path-check

Conversation

@SID-6921

Copy link
Copy Markdown

app.py picks the local folder vs. the hub repo by checking only for
model.safetensors:

pipe = ChitraTiny.from_pretrained(HERE if os.path.exists(os.path.join(HERE, "model.safetensors")) else "udgamlabs/Chitra-Tiny")

But ChitraTiny.from_pretrained (chitra_tiny.py) requires both
config.json and model.safetensors once it takes the local-path branch,
and does the config.json read with no try/except:

cfg = json.load(open(os.path.join(path_or_repo, "config.json")))

So if model.safetensors exists locally but config.json doesn't (partial
download, a weights file copied in by hand, etc.), the app crashes with
an unhandled FileNotFoundError instead of falling back to downloading
from the hub.

This PR makes app.py's local-path check require both files, which
matches what from_pretrained actually needs and lets it fall back to
the hub download when the local folder is incomplete.

app.py decided whether to load the model from the local folder or the
hub by checking only for model.safetensors. ChitraTiny.from_pretrained
needs both config.json and model.safetensors once it takes the local
path, with no handling for a missing config. If someone ends up with a
stray or partial model.safetensors locally (interrupted download,
manual copy, etc.) without config.json, the app crashes with an
unhandled FileNotFoundError instead of falling back to the hub
download.

Now the local-path check requires both files, matching what
from_pretrained actually needs.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 06:25

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

2 participants