A package for making predictions using a custom-trained ONNX floorplan/epc/proprty_image model
Project description
Smart Floorplan Predictor
A Python package for classifying images as EPCs, floorplans, property photos, or exterior shots using a pre-trained ONNX model.
Prerequisites
- Python 3.7 or higher
Installation
pip install smart-floorplan-predictor
Usage
import os
from smart_floorplan_predictor import FloorplanPredictor, FloorplanPredictorError
# --- Configuration for Private Repositories ---
# If the model is hosted in a private GitHub repository,
# you MUST provide a GitHub Personal Access Token (PAT).
# Set it as an environment variable:
# export GITHUB_TOKEN="your_github_pat_here"
# Ensure the token has the 'repo' scope to access private repository content.
github_token = os.environ.get("GITHUB_TOKEN")
try:
# Initialize the predictor
# If using a private repo, the token will be read from the environment variable
# or you can pass it directly: FloorplanPredictor(github_token="your_token")
predictor = FloorplanPredictor(github_token=github_token)
# Make a prediction using the path to an image file
image_path = "path/to/your/image.jpg"
predicted_class, confidence = predictor.predict_with_confidence(image_path)
print(f"Predicted Class: {predicted_class}")
print(f"Confidence: {confidence:.2%}")
# Or just get the class name directly
# predicted_class_only = predictor.predict(image_path)
# print(f"Predicted Class (direct): {predicted_class_only}")
except FloorplanPredictorError as e:
print(f"An error occurred: {e}")
# Handle specific errors, e.g., ModelDownloadError
Model Downloading
- The package automatically attempts to download the
model.onnxfile using the GitHub API if it's not found locally within the package directory (src/smart_floorplan_predictor/). This works even for files stored using Git LFS. - Private Repositories: Downloading from private GitHub repositories requires a
GITHUB_TOKENenvironment variable containing a valid Personal Access Token with thereposcope.
Common Errors & Troubleshooting
ModelDownloadError: ... 404 Not Found ...:- Check if the
GITHUB_TOKENenvironment variable is set correctly (if accessing a private repo). - Verify the token is valid, not expired, and has the
reposcope enabled in your GitHub Developer settings. - Confirm the repository owner, name, and model file path (
REPO_OWNER,REPO_NAME,MODEL_FILE_PATHconstants inpredictor.py) are correct.
- Check if the
ModelDownloadError: ... 403 Forbidden ...:- Usually indicates the provided
GITHUB_TOKENlacks the necessary permissions (reposcope) for a private repository.
- Usually indicates the provided
FloorplanPredictorError: GITHUB_TOKEN is required...:- You are trying to download from the default private repository location without providing a token. Set the
GITHUB_TOKENenvironment variable.
- You are trying to download from the default private repository location without providing a token. Set the
FileNotFoundErrororImageLoadError:- Ensure the image path passed to
predictorpredict_with_confidenceis correct and the file exists.
- Ensure the image path passed to
- ONNX Runtime Issues:
- Ensure
onnxruntimeis installed correctly for your OS and architecture.
- Ensure
Running Tests (Development)
- Clone the repository.
- Install development dependencies:
pip install -r requirements.txt(if available) orpip install pytest requests tqdm Pillow numpy onnxruntime. - Set the
GITHUB_TOKENenvironment variable if testing against the private repo. - Place test images (like
test_image.png) in the root directory. - Run the test script:
python test.py
Requirements
- Python >= 3.7
- requests
- numpy
- Pillow
- onnxruntime
- tqdm
License
MIT License
Author
Oliver Brown
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file floorplan_epc_detector-1.0.1.tar.gz.
File metadata
- Download URL: floorplan_epc_detector-1.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d2905b0981eead5323f85de23b76d81bf20c5d84ed356b850669439b932012c
|
|
| MD5 |
4efa2ffbca1bb989b81dc2d333b6c3d0
|
|
| BLAKE2b-256 |
8a7aa2d6f2a84299957f8bdb02de25daf6c17f4f090d00685010436a5282abe7
|
File details
Details for the file floorplan_epc_detector-1.0.1-py3-none-any.whl.
File metadata
- Download URL: floorplan_epc_detector-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e5074f6d2de42d9662eee8e7a4dec4a2753ee4f83cb6e79eea1845bc428fee3
|
|
| MD5 |
61689a5725a02db73123937b8a108503
|
|
| BLAKE2b-256 |
50ff88c31df2af4dcf0cd2ce61c2226f824dc15f9bb7e79beb190f02b5be6c6f
|