API 레퍼런스¶
Public API¶
- class ovkit.Model(model='', source=None, /, **kwargs)[소스]¶
기반 클래스:
objectAn OpenVINO model with automatic resolution, task detection, and IO.
One name, one call — and the input can come along in the same call:
r = Model("detect", "street.jpg") # runs now -> one Results r = Model("얼굴분석", "group.jpg") # Korean names work too for r in Model("track", 0): # webcam/video -> a stream ... ai = Model("face_match") # no input -> a reusable object
A photo, a sound file, or a piece of text answers with one result; a webcam index, a video file, or “mic” answers with a stream to iterate; a folder answers with a list.
Model("face_analyze")("group.jpg")(build first, call later) keeps working — the object form is the same thing.Capability names (
face_analyze,read_text,track,gaze, …) build aPipelinethat chains the models the answer needs. They behave exactly like a model: same sources, sameResults.ovkit.list_pipelines()lists them.- 매개변수:
model (str | Path) – A registered model name (
"rtdetr_r50"), a capability name ("face_analyze"), or a path to an IR.xml/.onnxfile.task – Override task auto-detection (
"detect"/"classify"/…).device – Default OpenVINO device (
"AUTO"/"CPU"/"GPU"/"NPU"). Can be overridden per call.precision – Target IR precision for conversion (defaults to the manifest value, or
fp16).**kwargs (Any) – Passed to the pipeline when
modelnames a capability (for exampleModel("face_analyze", attributes=("age_gender",))).source (Any)
**kwargs
- 반환 형식:
Any
- classmethod network(model, task=None, device='AUTO', precision=None)[소스]¶
Load one network, even when the name also names a capability.
Model("gaze")gives you the composed pipeline, which is what a caller wants — but the pipeline itself needs the raw gaze network, and so does anyone who wants to drive it by hand. This skips the capability dispatch in__new__()and always returns a plain model.
- property inputs: list[tuple[str, tuple[int, ...], str]]¶
Return
(name, shape, dtype)for each model input.Useful for non-image models (NLP / audio / time series): build matching tensors and pass them to
infer().
- infer(inputs, *, device=None)[소스]¶
Run the model on raw input tensor(s), returning
{name: ndarray}.The escape hatch for any model — including non-image ones (NLP / audio / time series) — where you provide the input tensors yourself (see
inputsfor the expected shapes). No image preprocessing is done.
- predict(source, *, device=None, imgsz=None, conf=0.25, stream=False, **kwargs)[소스]¶
Run prediction on
source.The input type is auto-detected. An image (path /
ndarray/ folder / video / cameraint) runs the vision pipeline. An audio file on a sound model is read, resampled, framed and decoded intoResultslike any other task. Anything else (a.npytensor, a raw non-imagendarray) is fed to the model directly and the raw{name: ndarray}outputs are returned.stream=Truereturns a generator for image sources.
- AUDIO_TASKS = frozenset({'noise_suppression', 'sound_classification'})¶
Tasks driven by audio rather than an image.
- class ovkit.Results(orig_img, task, names=None, *, boxes=None, masks=None, keypoints=None, probs=None, tensors=None, path=None)[소스]¶
기반 클래스:
objectContainer for a single image’s prediction.
- 매개변수:
- orig_img¶
The original HWC BGR image.
- task¶
"detect"/"classify"/"segment"/"pose".
- names¶
{id: class_name}mapping.
- boxes, masks, keypoints, probs
Populated according to
task; the others areNone.
- path¶
Source path, when the prediction came from a file.
- tensors¶
Raw
{output_name: ndarray}for tasks without a typed decoder (e.g. super-resolution, embeddings).Nonefor vision tasks.
- labels: list[str] | None¶
One label per box, when a pipeline knows something the class id does not (the word an OCR pipeline read, a face’s age and emotion). Takes the place of
name confinplot()andsummary().
- arrows: ndarray | None¶
(N, 4)arrows[x1, y1, x2, y2]to draw — a direction a number cannot show (where a face is looking, which way something moved).
- audio: tuple[ndarray, int] | None¶
(samples, sample_rate)for audio results;orig_imgthen holds the waveform, so plot/save work exactly as they do for a picture.
- elapsed_ms: float | None¶
How long inference took and where it ran (“CPU”/”GPU”/”NPU”). On an AI PC this pair is teaching material, so every result carries it.
- property found: list[dict]¶
What was found, as friendly dictionaries.
Each row:
{"name", "name_en", "score", "box", "pos"}—namein the display language ($OVKIT_LANG),name_enthe stable English key (hyphenated, e.g.cell-phone) that code compares against, andposa 9-grid position (“왼쪽 위”) for students who have not met coordinates yet. A classification result yields one row with no box.
- crop(i=None, pad=0.0)[소스]¶
Cut box
iout of the image (all boxes wheniisNone).padgrows the box by a fraction of its size — face attribute models want a little context around the detection.
- summary(max_items=5)[소스]¶
One human-readable line describing this result.
Every surface (CLI, web demo,
print(results)) renders through this, so a model’s answer reads the same everywhere — and reads as an answer (“cat 0.92”, “road 47% · car 8%”) rather than as tensor shapes.
- plot(line_width=2, font_scale=None, caption=True)[소스]¶
Render this result onto a copy of the image and return it.
Draws masks, boxes (with
name conflabels) and keypoints, then one caption —summary()— across the top.font_scaledefaults to a size derived from the image width, so a 320-px webcam frame and a 4K photo are equally readable; passcaption=Falseto leave the top of the image clean.
- class ovkit.Boxes(data)[소스]¶
기반 클래스:
objectDetection boxes in
xyxypixel coordinates with scores and classes.datais an(N, 6)array of[x1, y1, x2, y2, conf, cls].- 매개변수:
data (np.ndarray)
- class ovkit.Masks(data)[소스]¶
기반 클래스:
objectInstance segmentation masks:
(N, H, W)boolean/float array.- 매개변수:
data (np.ndarray)
- class ovkit.Keypoints(data)[소스]¶
기반 클래스:
objectPose keypoints:
(N, K, 3)array of[x, y, confidence].- 매개변수:
data (np.ndarray)
Composed pipelines¶
Composed capabilities — several models chained into one intuitive call.
Model("face_detection") gives you boxes. What you usually want is who is in
the frame, how old they look and whether they are smiling — which is a
detector plus three more models plus the code to crop and join them. That is
what a pipeline is:
from ovkit import Model
- for r in Model(“face_analyze”)(“group.jpg”):
print(r.summary()) # 2 faces: age 31 · male 98% · happy 92%, … r.save(“faces.jpg”)
Every pipeline takes the same sources as Model (path, ndarray,
folder, video, camera index) and returns the same Results, so
they are drop-in replacements for a model anywhere in your code.
ovkit.list_pipelines() shows every capability and what it does.
- ovkit.pipelines.build_pipeline(name, device='AUTO', **kwargs)[소스]¶
Build a composed pipeline by name — normally reached via
Model(name).>>> from ovkit import Model >>> Model("face_analyze")("group.jpg")[0].summary() >>> Model("read_text")("sign.jpg")[0].text >>> Model("track")(0) # webcam, ids kept across frames
- ovkit.pipelines.capability_using(network)[소스]¶
Which capability drives this network, if one does.
A multi-input model like
gaze_estimation_adas_0002cannot be run from a picture — but a pipeline builds its inputs. Looking that up here lets the error say so instead of leaving the caller stuck.
- ovkit.pipelines.is_pipeline(name)[소스]¶
True when
nameis a composed capability rather than one network.
- ovkit.pipelines.PIPELINES: dict[str, type[Pipeline]] = {'anonymize': <class 'ovkit.pipelines.privacy.Anonymizer'>, 'attendance': <class 'ovkit.pipelines.classroom.Attendance'>, 'attention': <class 'ovkit.pipelines.attention.AttentionAnalyzer'>, 'count': <class 'ovkit.pipelines.classroom.Counter'>, 'drowsiness': <class 'ovkit.pipelines.temporal.DrowsinessMonitor'>, 'exercise': <class 'ovkit.pipelines.classroom.RepCounter'>, 'face_analyze': <class 'ovkit.pipelines.analyze.FaceAnalyzer'>, 'face_match': <class 'ovkit.pipelines.reid.ReID'>, 'gaze': <class 'ovkit.pipelines.gaze.GazeEstimator'>, 'gesture': <class 'ovkit.pipelines.temporal.GestureRecognizer'>, 'person_analyze': <class 'ovkit.pipelines.analyze.PersonAnalyzer'>, 'posture': <class 'ovkit.pipelines.classroom.PostureCoach'>, 'read_plate': <class 'ovkit.pipelines.plates.PlateReader'>, 'read_text': <class 'ovkit.pipelines.text.TextReader'>, 'scene': <class 'ovkit.pipelines.scene.SceneReport'>, 'teach': <class 'ovkit.pipelines.teach.Teach'>, 'track': <class 'ovkit.pipelines.tracking.Tracker'>, 'vehicle_analyze': <class 'ovkit.pipelines.analyze.VehicleAnalyzer'>}¶
Every composed capability, by the name
vis()accepts.
- class ovkit.pipelines.Pipeline(device='AUTO')[소스]¶
기반 클래스:
objectSeveral models composed into one capability.
Subclasses implement
run()for a single image; source handling, model caching and lazy loading come from here.- 매개변수:
device (str)
- description: str = ''¶
One-line description, shown by
ovkit.list_pipelines().
- task¶
Mirrors
Model.taskso a pipeline is a drop-in for a model.
- model(name)[소스]¶
Return a sub-model, loading (and downloading) it on first use.
Always a single network: a pipeline’s parts are networks, and asking for one by a name that also names a capability (
gazenames both) would otherwise hand back a pipeline — in the worst case this one. Loading is lazy, so a pipeline configured without, say, head pose never downloads that model.
- class ovkit.pipelines.FaceAnalyzer(device='AUTO', attributes=None, detector=None)[소스]¶
기반 클래스:
_DetectAndDescribeFaces plus age, gender and emotion — the usual “who is in frame” answer.
>>> from ovkit import vis >>> for r in vis("face_analyze")("group.jpg"): ... print(r.summary()) # 2 faces: age 31 · male 98% · happy 92%, ... ... r.save("faces.jpg")
attributespicks what to run;head_poseandface_landmarksare off by default because each is another model to download.- description: str = 'Detect faces, then read age, gender and emotion from each.'¶
One-line description, shown by
ovkit.list_pipelines().
- available: tuple[str, ...] = ('age_gender', 'emotion', 'head_pose', 'face_landmarks')¶
Attribute models available, in the order their answers are joined.
- class ovkit.pipelines.PersonAnalyzer(device='AUTO', attributes=None, detector=None)[소스]¶
기반 클래스:
_DetectAndDescribePeople plus what they are wearing or carrying.
>>> from ovkit import vis >>> vis("person_analyze")("street.jpg")[0].summary() '3 persons: male 0.98 · long pants 0.95 · bag 0.71, ...'
- description: str = 'Detect people, then read their attributes (bag, hat, sleeves, ...).'¶
One-line description, shown by
ovkit.list_pipelines().
- available: tuple[str, ...] = ('person_attributes',)¶
Attribute models available, in the order their answers are joined.
- class ovkit.pipelines.VehicleAnalyzer(device='AUTO', attributes=None, detector=None)[소스]¶
기반 클래스:
_DetectAndDescribeVehicles plus their type and colour.
>>> from ovkit import vis >>> vis("vehicle_analyze")("parking.jpg")[0].summary() '2 vehicles: type: car (0.98) · color: black (0.83), ...'
- description: str = 'Detect vehicles, then read type (car/bus/truck/van) and colour.'¶
One-line description, shown by
ovkit.list_pipelines().
- available: tuple[str, ...] = ('vehicle_attributes',)¶
Attribute models available, in the order their answers are joined.
- class ovkit.pipelines.TextReader(device='AUTO', detector='text_detection', recognizer='text_recognition')[소스]¶
기반 클래스:
PipelineText detection + text recognition.
>>> from ovkit import vis >>> r = vis("read_text")("receipt.jpg")[0] >>> r.text # every word, reading order (top to bottom) >>> r.labels # the word on each box >>> r.save("read.jpg") # boxes labelled with what they say
- description: str = 'Find text regions and read them (detection + recognition).'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.Tracker(device='AUTO', detector='detect', iou=0.3, max_age=30)[소스]¶
기반 클래스:
PipelineA detector plus IoU association, emitting a track id per box.
- 매개변수:
- description: str = 'Detect objects and keep a stable id for each across frames.'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.GazeEstimator(device='AUTO', detector='face_detection', eye_scale=0.55, gaze_model='gaze_estimation_adas_0002')[소스]¶
기반 클래스:
PipelineFace detection + landmarks + head pose + gaze, in one call.
>>> from ovkit import vis >>> r = vis("gaze")("portrait.jpg")[0] >>> r.summary() # '1 face: looking left and slightly up' >>> r.tensors["gaze"] # (N, 3) unit vectors, one per face >>> r.save("gaze.jpg") # an arrow drawn from each eye
eye_scalesizes the eye crop as a fraction of the distance between the two eyes. The zoo demo sizes it from eye-corner landmarks, which the five-point landmark model does not provide; 0.55 is the equivalent width.- description: str = 'Estimate where a face is looking (detection + landmarks + head pose + gaze).'¶
One-line description, shown by
ovkit.list_pipelines().
- gaze_model¶
The gaze network. Spelled out because “gaze” now names this pipeline, and a pipeline cannot be its own part.
- class ovkit.pipelines.ReID(device='AUTO', embedder='face_reid', threshold=0.5)[소스]¶
기반 클래스:
PipelineEmbed crops and match them against a named gallery.
- 매개변수:
embedder (str) – Registered embedding model:
face_reid(faces),person_reidorvehicle_reid_0001(whole bodies / cars),image_retrieval(scenes).threshold (float) – Below this similarity
who()answersNoneinstead of naming the closest gallery entry — without it every stranger gets somebody’s name.device (str)
- description: str = 'Match faces (or people, or vehicles) against a gallery you build.'¶
One-line description, shown by
ovkit.list_pipelines().
- add(label, image)[소스]¶
Put an image in the gallery under
label.Adding the same label twice averages the descriptors, so several photos of one person give a more robust match than any single one.
- class ovkit.pipelines.AttentionAnalyzer(device='AUTO', detector='detect', reach=2.0, steps=120)[소스]¶
기반 클래스:
PipelineGaze plus object detection: name the object on the line of sight.
>>> from ovkit import Model >>> r = Model("attention")("desk.jpg")[0] >>> r.text # '1 person looking at: laptop' >>> r.arrows # the ray drawn from each eye
- description: str = 'Work out which detected object a person is looking at (gaze + detection).'¶
One-line description, shown by
ovkit.list_pipelines().
- reach¶
How far to follow the ray, in multiples of the image diagonal.
- class ovkit.pipelines.Anonymizer(device='AUTO', detector='face_detection', plates=False, method='pixelate', strength=1.0)[소스]¶
기반 클래스:
PipelineBlur or pixelate every face (and optionally every number plate).
- 매개변수:
plates (bool) – Also redact number plates. Costs one more model.
method (str) –
"pixelate"(visibly redacted) or"blur"(softer).strength (float) – Bigger is stronger: pixel block size and blur radius both scale with the region, so a small distant face is redacted as thoroughly as a close one.
picture (The result's image is the redacted)
and (so r.plot())
kept (r.save() never hand back the original by accident. The regions are)
covered. (in r.tensors["regions"] if you need to audit what was)
device (str)
detector (str)
- description: str = 'Blur every face (and number plate) so a picture can be shared.'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.DrowsinessMonitor(device='AUTO', detector='face_detection', seconds=1.0, nod_pitch=20.0, eye_scale=0.55, clock=None)[소스]¶
기반 클래스:
PipelineDriver monitoring: are the eyes closed, and for how long?
>>> from ovkit import Model >>> monitor = Model("drowsiness") >>> for r in monitor.predict(0, stream=True): # webcam ... print(r.summary()) # 'awake' ... 'EYES CLOSED 1.4s — drowsy'
Four models nobody can use alone: a face detector, the five-point landmark model for where the eyes are,
open_closed_eye_0001for their state, and head pose for a nodding head. The pipeline adds what none of them has — time: a blink is a fifth of a second, so only a closure lasting longer thansecondsis drowsiness.- 매개변수:
- description: str = 'Watch a face over time and warn when the eyes stay shut (driver monitoring).'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.GestureRecognizer(device='AUTO', model_name='common_sign_language_0002', classes='sign_language12')[소스]¶
기반 클래스:
PipelineHand gestures from a moving picture, not a still one.
>>> from ovkit import Model >>> gestures = Model("gesture") >>> for r in gestures.predict(0, stream=True): ... print(r.summary()) # 'collecting frames (3/8)' ... 'thumb up 0.94'
common_sign_language_0002takes a clip of eight frames. Fed a single image it is shown the same photograph eight times, which is not a gesture — so this keeps a rolling buffer of the last eight frames and classifies the motion across them.- description: str = 'Recognise hand gestures from the last few frames (needs motion, not a photo).'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.PlateReader(device='AUTO', detector='license_plate', recognizer='text_recognition', attributes=True)[소스]¶
기반 클래스:
PipelineDetect vehicles and plates, read the plates, describe the vehicles.
>>> from ovkit import Model >>> r = Model("read_plate")("gate.jpg")[0] >>> r.text # 'black car — 12GA3456' >>> r.to_dict()["boxes"] # each box with its own text
- description: str = 'Read number plates and describe the vehicle each belongs to.'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.SceneReport(device='AUTO', detector='detect', segment=True, faces=True)[소스]¶
기반 클래스:
PipelineDetection + segmentation + faces, summarised as one line.
Each part can be switched off:
Model("scene", segment=False)skips the segmentation model (and its download) entirely.- description: str = 'Describe a whole picture: objects, what the space is made of, and the people.'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.Teach(device='AUTO', mode='photo', k=5, load=None)[소스]¶
기반 클래스:
PipelineLearn categories from examples; recognise them like any other model.
- description: str = 'Teach your own AI from a few examples — no GPU training (5 modes).'¶
One-line description, shown by
ovkit.list_pipelines().
- learn(label, source)[소스]¶
Add examples of
label: a folder, one image path, or an array.Returns how many examples were stored. Call again with the same label to add more — more examples make a steadier answer.
- score(source)[소스]¶
Grade the AI on a folder of subfolders (one per true label).
- 매개변수:
source (Any)
- 반환 형식:
Score
- 배우기(label, source)¶
Add examples of
label: a folder, one image path, or an array.Returns how many examples were stored. Call again with the same label to add more — more examples make a steadier answer.
- 맞혀봐(source)¶
The best label and its confidence for one image.
- 점수(source)¶
Grade the AI on a folder of subfolders (one per true label).
- 매개변수:
source (Any)
- 반환 형식:
Score
- 저장(name, dir=None)¶
Write everything learned to
<Documents>/ovkit/<name>.json.
- class ovkit.pipelines.Attendance(device='AUTO', roster=None, threshold=0.5, detector='face_detection')[소스]¶
기반 클래스:
PipelineTake the roll with face matching against a roster you provide.
>>> att = Model("attendance", roster="class_photos/") >>> for r in att.predict(0, stream=True): ... print(r) # 출석 3: 철수, 영희, 민수 >>> att.save_csv("roll.csv") # name,status,score
The roster folder holds either one photo per student (
철수.jpg) or a folder per student with several photos (better). Matching is the same cosine gallery asface_match, run on every detected face crop.- description: str = 'Face-match against a roster folder and keep who is present.'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.Counter(device='AUTO', detector='detect', what=None)[소스]¶
기반 클래스:
PipelineCount what a detector sees, optionally only one kind of thing.
>>> Model("count", "desk.jpg").summary() # 'pencil 3 · cup 1' >>> Model("count", 0, what="person") # live head-count
- description: str = 'Count the objects in view, by kind (optionally just one kind).'¶
One-line description, shown by
ovkit.list_pipelines().
- what¶
English class key to count exclusively (
person,cell-phone…).
- class ovkit.pipelines.PostureCoach(device='AUTO', degrees=25.0, seconds=5.0, clock=None)[소스]¶
기반 클래스:
PipelineWarn when the neck stays bent past a threshold — the turtle-neck timer.
>>> for r in Model("posture", 0): ... print(r) # '자세 좋아요 (12°)' ... '목이 34° — 자세 고치세요'
A single glance down is not bad posture, so the warning needs the angle to stay past
degreesforseconds— the same time-not-frames logic as drowsiness. Works best with the camera at screen height, face-on or side-on.- description: str = 'Watch the neck angle over time and warn when posture slips.'¶
One-line description, shown by
ovkit.list_pipelines().
- class ovkit.pipelines.RepCounter(device='AUTO', kind='squat')[소스]¶
기반 클래스:
PipelineCount exercise repetitions from the pose stream.
>>> for r in Model("exercise", 0, kind="squat"): ... print(r) # 'squat x 12 (down)'
A rep is one full cycle through hysteresis: the joint angle must drop below the exercise’s down threshold and come back above up — so a half-hearted bounce in the middle never counts.
- description: str = 'Count squats / push-ups by tracking joint angles over time.'¶
One-line description, shown by
ovkit.list_pipelines().
Exceptions¶
Exception hierarchy for ovkit.
All errors raised by ovkit derive from OVKitError so callers can catch
the whole family with a single except.
- exception ovkit.core.errors.OVKitError[소스]¶
기반 클래스:
ExceptionBase class for every error raised by ovkit.
- exception ovkit.core.errors.ModelNotFoundError[소스]¶
기반 클래스:
OVKitErrorA model name could not be resolved to a local path or manifest entry.
- exception ovkit.core.errors.OfflineError[소스]¶
기반 클래스:
OVKitErrorNetwork access was required but
OVKIT_OFFLINE=1is set.
- exception ovkit.core.errors.DownloadError[소스]¶
기반 클래스:
OVKitErrorA model artifact failed to download or failed its integrity check.
- exception ovkit.core.errors.GatedModelError[소스]¶
기반 클래스:
DownloadErrorA Hugging Face repo is gated and requires authentication.
- exception ovkit.core.errors.MirrorMissingError[소스]¶
기반 클래스:
DownloadErrorA model is expected on the ovkit HF mirror but is not (yet) there.
- exception ovkit.core.errors.ConversionError[소스]¶
기반 클래스:
OVKitErrorConversion of a source model (ONNX/torch) to OpenVINO IR failed.
- exception ovkit.core.errors.TaskDetectionError[소스]¶
기반 클래스:
OVKitErrorThe task (detect/classify/segment/pose) could not be determined.
- exception ovkit.core.errors.LicenseError[소스]¶
기반 클래스:
OVKitErrorA model carries a non-permissive license and may not be registered.
Core modules¶
Model registry: load the manifest and resolve a name to a source spec.
The registry is intentionally data-driven. Models live in YAML manifests
(src/ovkit/manifests/*.yaml plus any user-supplied paths), never hardcoded
in Python. Adding a model is a one-line YAML edit.
- class ovkit.core.registry.ModelEntry(name, src, task=None, description=None, license=None, precision='fp16', repo=None, filename=None, subfolder=None, url=None, sha256=None, imgsz=None, license_url=None, fallback=None, preprocess=<factory>, postprocess=<factory>, extra=<factory>)[소스]¶
기반 클래스:
objectA single resolved manifest entry.
Attributes mirror the YAML schema documented in
manifests/models.yaml.
- exception ovkit.core.registry.OVKitManifestError[소스]¶
기반 클래스:
ExceptionRaised when a manifest file cannot be parsed.
- ovkit.core.registry.reload()[소스]¶
Clear the cached manifest (call after editing manifests at runtime).
- 반환 형식:
None
- ovkit.core.registry.resolve(name, _seen=None)[소스]¶
Resolve a registered model
nameto aModelEntry.Returns
Noneif the name is not in any manifest. Analiasentry ({alias: other_name}) transparently resolves to its target, so friendly capability names (e.g.face_detection->face_detection_0205) work. The entry’s license is validated to be permissive; non-permissive entries raiseLicenseErrorso they can never load.- 매개변수:
- 반환 형식:
ModelEntry | None
Artifact download + cache with atomic writes, integrity checks, offline mode.
This module turns a ModelEntry into a concrete
local file (an .onnx or .xml) ready for conversion/loading. It does not
know about OpenVINO; it only fetches bytes and verifies them.
Robustness guarantees (spec §6.5):
Atomic save — download to a temp file,
renameinto place on success.Integrity — verify
sha256from the manifest when present.Offline —
OVKIT_OFFLINE=1blocks the network; cache-only.
- ovkit.core.download.OVKIT_MIRROR = 'leeyunjai/ovkit-models'¶
HF mirror that hosts OMZ-derived (Apache-2.0) IR for ovkit.
- ovkit.core.download.model_cache_dir(name)[소스]¶
Return (and create) the cache directory for a model
name.
- ovkit.core.download.downloads_dir(name)[소스]¶
Return (and create) the directory holding raw downloaded sources.
- ovkit.core.download.fetch(entry)[소스]¶
Ensure the source artifact for
entryis present locally and return it.Resolution order:
Offline (
OVKIT_OFFLINE=1): return a cached copy or raise.The entry’s primary source.
entry.fallback(e.g. the upstream original) if the primary fails — so a mirror outage degrades to the original host instead of breaking.
- 매개변수:
entry (ModelEntry)
- 반환 형식:
Convert source models (ONNX / IR) to OpenVINO IR, with a conversion cache.
Conversion runs at most once per (name, precision): the resulting IR is
written to the model cache and reused on subsequent loads.
- ovkit.core.convert.cached_ir(name, precision)[소스]¶
Return the cached IR
.xmlfor(name, precision)if it exists.
- ovkit.core.convert.to_ir(source, name, precision='fp16')[소스]¶
Convert
sourceto OpenVINO IR and return the cached.xmlpath.sourcemay already be IR (.xml) — in that case it is passed through unchanged. ONNX sources are converted withopenvino.convert_modeland serialized (compressing weights to fp16 whenprecision == "fp16"). The result is cached so conversion happens only once.
Thin OpenVINO runtime wrapper: device abstraction, sync + async inference.
A Backend owns a compiled model for a chosen device and exposes both a
single-shot infer() (synchronous) and a throughput-oriented
infer_batch() built on ov.AsyncInferQueue for streams/folders/video.
- ovkit.core.backend.available_devices()[소스]¶
Return device names visible to OpenVINO (e.g.
["CPU", "GPU", "NPU"]).
- class ovkit.core.backend.Backend(model, device='AUTO')[소스]¶
기반 클래스:
objectA compiled model bound to a device, with sync and async inference.
- 매개변수:
- property input_shape: tuple[int, ...]¶
Partial shape of the first input as a tuple (
-1for dynamic).
- infer_batch(feeds, callback=None, jobs=0)[소스]¶
Run inference over
feedsusing an async queue (throughput mode).Yields result dicts in completion order. When
callbackis given it is invoked ascallback(index, result); otherwise results are collected and yielded.jobssets the number of in-flight requests (0lets OpenVINO choose the optimal number).
Task auto-detection.
Priority (spec §4):
The manifest
taskfield, if the model came from the registry.The IR
rt_infometadata (model_info/taskormodel_type).A heuristic over the output tensor signatures.
Otherwise raise
TaskDetectionErrorasking for an explicittask=.
- ovkit.core.tasks.KNOWN_TASKS = ('detect', 'classify', 'segment', 'pose', 'face')¶
Tasks ovkit knows how to attach an adapter for.
Recognition adapters¶
Task adapters: map a generic backend + image to task-specific Results.
The get_adapter() factory selects the adapter for a detected task.
detect (DETR / SSD / boxes+labels / YOLOv2), classify, segment, and
pose have typed decoders; every other image task falls back to
GenericAdapter, which returns the raw output tensors.
- class ovkit.recognize.BaseAdapter(*, imgsz=640, preprocess=None, postprocess=None, names=None)[소스]¶
기반 클래스:
objectCommon configuration + interface for every task adapter.
- 매개변수:
- preprocess_square(image, rgb=True)[소스]¶
Resize to
imgszsquare, normalize, and return an NCHW float tensor.
- static labels_beside(model_path)[소스]¶
Class names from a
labels.txtnext to the model, if present.Keeping labels as data (one name per line, mirrored with the model) avoids hardcoding a thousand ImageNet strings in the package and works for any dataset a model was trained on.
- model_input_hw(backend)[소스]¶
Return the model’s static spatial
(h, w)(last two dims), orimgsz.Works for 4-D
[N,C,H,W]and higher-rank inputs (e.g. video clips[N,C,T,H,W]); only the trailing two dims are taken asH, W. Raises a clear error for multi-input models, which a single image cannot drive automatically.
- class ovkit.recognize.ClassifyAdapter(*, imgsz=640, preprocess=None, postprocess=None, names=None)[소스]¶
기반 클래스:
BaseAdapterAdapter for image classification.
- 매개변수:
- class ovkit.recognize.DetectAdapter(**kwargs)[소스]¶
기반 클래스:
BaseAdapterAdapter for object detection (DETR and SSD output families).
- 매개변수:
kwargs (Any)
- class ovkit.recognize.FaceAdapter(*, imgsz=640, preprocess=None, postprocess=None, names=None)[소스]¶
기반 클래스:
BaseAdapterAdapter for face-analysis models (detection, attributes, landmarks).
- 매개변수:
- class ovkit.recognize.GenericAdapter(task='generic', **kwargs)[소스]¶
기반 클래스:
BaseAdapterRun an image through a model and return raw output tensors.
- 매개변수:
task (str)
kwargs (Any)
- class ovkit.recognize.OCRAdapter(*, imgsz=640, preprocess=None, postprocess=None, names=None)[소스]¶
기반 클래스:
BaseAdapterAdapter for text recognition (greedy CTC).
- 매개변수:
- class ovkit.recognize.PoseAdapter(*, imgsz=640, preprocess=None, postprocess=None, names=None)[소스]¶
기반 클래스:
BaseAdapterAdapter for keypoint/pose estimation (multi-instance heatmap peaks).
- 매개변수:
- class ovkit.recognize.SegmentAdapter(*, imgsz=640, preprocess=None, postprocess=None, names=None)[소스]¶
기반 클래스:
BaseAdapterAdapter for semantic and instance segmentation.
- 매개변수:
- ovkit.recognize.VISION_TASKS = frozenset({'classify', 'detect', 'face', 'ocr', 'optical_character_recognition', 'pose', 'segment'})¶
Tasks with a typed decoder (the rest use the generic raw-output adapter).
- ovkit.recognize.get_adapter(task, **kwargs)[소스]¶
Instantiate the adapter for
task.Vision tasks (detect/classify/segment/pose) get their typed decoder; any other task falls back to
GenericAdapter, which runs the model on the image and returns raw output tensors.- 매개변수:
- 반환 형식:
Detection adapter — DETR-family and SSD/DetectionOutput models.
Two output families are auto-detected from the model’s output signature:
DETR (RT-DETR / D-FINE): a class-logits tensor
[N, Q, C]and a box tensor[N, Q, 4]in normalizedcxcywhform. No NMS — each query is one prediction. Sigmoid the logits, take the best class per query, threshold.SSD / DetectionOutput (most OMZ detectors: face/person/vehicle): a single
[1, 1, N, 7]tensor of[image_id, label, conf, x_min, y_min, x_max, y_max]with normalized coordinates. Threshold byconf.
Preprocessing follows the model’s own input size (OMZ models are fixed-size) and
sensible per-family defaults (DETR: RGB [0,1]; SSD: raw BGR [0,255]),
both overridable via the manifest preprocess block.
- class ovkit.recognize.detect.DetectAdapter(**kwargs)[소스]¶
기반 클래스:
BaseAdapterAdapter for object detection (DETR and SSD output families).
- 매개변수:
kwargs (Any)
Image utilities¶
Image utilities — not models. Resize, letterbox, color, crop, zoom.
Everything here works on plain numpy HWC arrays (OpenCV’s BGR convention by
default) so the rest of ovkit never has to depend on a particular image type.
- ovkit.image.ops.letterbox(img, size=640, color=(114, 114, 114))[소스]¶
Resize preserving aspect ratio and pad to
size.Returns
(padded_image, scale, (pad_x, pad_y))so detections can be mapped back to the original image coordinates.