No project description provided
Project description
Dwave SONA Core
迪威智能 SONA 服務專用核心開發套件
安裝與使用
開發環境需求
- Python 3.8 或更新版本
- poetry
- ffmpeg
安裝與使用
- 環境建構
$ pip install poetry
- 下載與安裝
$ export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
$ poetry add git+ssh://git@github.com/DeepWaveInc/dwave-sona-core.git
- 撰寫 Inferencer 模組
from typing import Dict, List
from loguru import logger
from pydantic import BaseModel, Field
from sona.core.inferencer import InferencerBase
from sona.core.messages import File, Result
class InputParamSchema(BaseModel):
param1: int = Field(42, description="this is the value of param1")
param2: str = Field("43", description="this is the value of param2")
class InputFilesSchema(BaseModel):
origin: str = Field("data/test.mp3", description="this is the value of origin")
class SimpleInferencer(InferencerBase):
name = "mock"
description = "This is a simple inferencer"
input_params_schema = InputParamSchema()
input_files_schema = InputFilesSchema()
def on_load(self) -> None:
logger.info(f"Download {self.__class__.__name__} models...")
def inference(self, params: Dict, files: List[File]) -> Result:
logger.info(f"Get params {params}")
logger.info(f"Get files {files}")
return Result(
files=[File(label="output", path=files[0].path)],
data={"output_key": "output_val"},
)
if __name__ == "__main__":
inferencer = SimpleInferencer()
inferencer.cmd()
- 測試指令
$ python simple.py --help
Usage: simple.py [OPTIONS] <filepath:origin>
This is a simple inferencer
Options:
--param2 <string> this is the value of param2
--param1 <integer> this is the value of param1
--help Show this message and exit.
$ python tests/simple.py tests/simple.py
2023-10-17 02:18:41.702 | INFO | __main__:on_load:25 - Download SimpleInferencer models...
2023-10-17 02:18:41.702 | INFO | __main__:inference:28 - Get params {'param2': '43', 'param1': 42}
2023-10-17 02:18:41.703 | INFO | __main__:inference:29 - Get files [File(label='origin', path='tests/simple.py', metadata={})]
{"files":[{"label":"output","path":"tests/simple.py","metadata":{}}],"data":{"output_key":"output_val"}}
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
sona_core-2.0.0.tar.gz
(14.1 kB
view details)
Built Distribution
sona_core-2.0.0-py3-none-any.whl
(22.9 kB
view details)
File details
Details for the file sona_core-2.0.0.tar.gz
.
File metadata
- Download URL: sona_core-2.0.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-28-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75bbe1f9e3018ee41a6b0850edd428fae5fdab548e68adbbfd31570e2f825fa0 |
|
MD5 | 0abafdb4eb3da712930c95e616e9307e |
|
BLAKE2b-256 | 7dc674629dd34262214c570de32b192bb872c5b46d6943cf29587b780289a410 |
File details
Details for the file sona_core-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: sona_core-2.0.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-28-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f75aa3b4c2f14ab32cb37b02836804c46c9eacfd89a1706a9a80ef498161d3a4 |
|
MD5 | 1d35b341f3605bf7d3df73f462fa8bc8 |
|
BLAKE2b-256 | a2ea8d75655a15a9e69663e453b3c1a62c3eabd99849a8d221508ed7c79f176d |