Skip to content

Fix Streamlit app path resolution for model and weight files#135

Open
sushantkhemalapure wants to merge 1 commit intohumanai-foundation:mainfrom
sushantkhemalapure:fix/app-streamlit-path-resolution
Open

Fix Streamlit app path resolution for model and weight files#135
sushantkhemalapure wants to merge 1 commit intohumanai-foundation:mainfrom
sushantkhemalapure:fix/app-streamlit-path-resolution

Conversation

@sushantkhemalapure
Copy link
Copy Markdown

Summary

This PR improves reliability of the Streamlit app by fixing how model and weight file paths are resolved.

Problem

The app previously used hardcoded relative paths (e.g., ../../weights/...), which only work when executed from a specific working directory. Running the app from other locations caused missing file errors.

Solution

  • Introduced APP_DIR to resolve paths relative to the app file location
  • Added resolve_existing_path(...) helper that:
    • checks environment variable overrides
    • falls back to common local paths
    • raises clear errors if files are not found

Applied to

  • CRAFT weights
  • CRAFT refiner weights
  • OCR model directory
  • OCR processor directory

Impact

  • No changes to OCR logic, UI, or preprocessing
  • Improves portability and developer experience
  • Makes app execution more robust across environments

Testing

  • Verified app runs correctly from different working directories
  • Verified fallback and error handling behavior

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.

1 participant