Skip to main content

SGRF library development setup

Prerequisites

  • Python 3.11
  • PIP

Development

Installation

  1. Create/activate virtual environment
  2. Install required packages with pip install -r requirements.txt

Create new algorithm

To create a new algorithm, use algorithm creation script: ./scripts/generate_algorithm.py

Validate algorithms

To validate algorithms use scripts located in ./validation directory. Json files with validation results are located in ./validation/results directory

Usage

Import library

To use library in external project, use pip install sgrf.

Sample use cases

To predict gesture on selected image, run the code below. You can select desired algorithm by using values on ALGORITHM enum. Some algorithms require their own payload (e.g. hand coordinates or background image without hand). You can import specific payload from sgrf.algorithms.<alg>.<alg>_payload.

import cv2
from sgrf import classify
from sgrf.data.algorithm import ALGORITHM
from sgrf.models.image_payload import ImagePayload

image = cv2.imread("resources/image.jpg")
result = classify(algorithm=ALGORITHM.EID_SCHWENKER, payload=ImagePayload(image=image))

print(result)

To show image processed by the selected algorithm, run:

import cv2
from sgrf import process_image
from sgrf.data.algorithm import ALGORITHM
from sgrf.models.image_payload import ImagePayload

image = cv2.imread("resources/image.jpg")
processed_image = process_image(algorithm=ALGORITHM.EID_SCHWENKER, payload=ImagePayload(image=image))

cv2.imshow("Image", processed_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

To learn your own algorithm's model (e.g. on other image base than ours), run:

import cv2
from sgrf import learn
from sgrf.data.algorithm import ALGORITHM
from sgrf.data.gesture import GESTURE
from sgrf.models.learning_data import LearningData

image = cv2.imread("resources/image.jpg")
acc, loss = learn(algorithm=ALGORITHM.EID_SCHWENKER, target_model_path="models",
                  learning_data=[LearningData(image_path="resources/image.jpg", label=GESTURE.FIVE)] * 10)

print(acc, loss)

Usage with Nextcloud

To use SGRF with Nextcloud BDGS, complete following steps:

  1. Create ./env file.
  2. Copy ./example.env contents to ./env file. Adjust settings with credentials to Nextcloud.
  3. Place ./env file in same directory as the script you want to run, or edit running configuration to use .env file as environmental variables source (sample configurations for PyCharm are located in ./.idea\runConfigurations).
  4. Use SGRFDatasetLoader.get_learning_files_nextcloud() function to load images from Nextcloud.

Sample usage:

import cv2
from scripts.loaders import SGRFDatasetLoader

# files = SGRFDatasetLoader.get_learning_files(limit=images_amount, limit_people=people_amount)
files = SGRFDatasetLoader.get_learning_files_nextcloud(limit_people=2, limit=100)
for image_file in files:
  image = cv2.imread(image_file[0])

Release files for sgrf 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sgrf 3.2.0
File Size Uploaded
sgrf-3.2.0.tar.gz 46.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for sgrf 3.2.0
File Interpreter ABI Platform
sgrf-3.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 93.7 MB

Release files / sgrf-3.2.0.tar.gz

Download URL sgrf-3.2.0.tar.gz
Size 46.9 MB
Tags Source
SHA-256 checksum
How to use checksums
b23e45fa4f1376661302ae777f966244ac45306cb830abcfcf877fde9d21e1d2
BLAKE2b-256 checksum
How to use checksums
103c8c60fe41c5ffb73fce0950102c2f1386d3c98ff79a6ae6df7cb23b998e8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / sgrf-3.2.0-py3-none-any.whl

Download URL sgrf-3.2.0-py3-none-any.whl
Size 46.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7bc6c852d163c32f8a0e9a57e2d6e4fa181bd2da63df27387de5a1dc42c2ce73
BLAKE2b-256 checksum
How to use checksums
46d9cf8a4538ed4caea21555820b9841b274a461eca9032198eb3b2c03c8421e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files

3.1.0

2 release files

3.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page