runapi-omnihuman 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runapi/omnihuman/__init__.py +24 -0
- runapi/omnihuman/client.py +33 -0
- runapi/omnihuman/contract_gen.py +45 -0
- runapi/omnihuman/py.typed +0 -0
- runapi/omnihuman/resources/__init__.py +8 -0
- runapi/omnihuman/resources/audio_to_video.py +39 -0
- runapi/omnihuman/resources/human_identification.py +40 -0
- runapi/omnihuman/resources/subject_detection.py +40 -0
- runapi/omnihuman/types.py +61 -0
- runapi_omnihuman-0.1.1.dist-info/METADATA +66 -0
- runapi_omnihuman-0.1.1.dist-info/RECORD +12 -0
- runapi_omnihuman-0.1.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""OmniHuman client for RunAPI."""
|
|
2
|
+
|
|
3
|
+
from runapi.core import (
|
|
4
|
+
AuthenticationError,
|
|
5
|
+
InsufficientCreditsError,
|
|
6
|
+
NotFoundError,
|
|
7
|
+
RateLimitError,
|
|
8
|
+
TaskFailedError,
|
|
9
|
+
TaskTimeoutError,
|
|
10
|
+
ValidationError,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from .client import OmnihumanClient
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"OmnihumanClient",
|
|
17
|
+
"AuthenticationError",
|
|
18
|
+
"RateLimitError",
|
|
19
|
+
"InsufficientCreditsError",
|
|
20
|
+
"NotFoundError",
|
|
21
|
+
"ValidationError",
|
|
22
|
+
"TaskFailedError",
|
|
23
|
+
"TaskTimeoutError",
|
|
24
|
+
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""OmniHuman client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import ClientOptions, HttpClient, resolve_api_key
|
|
8
|
+
|
|
9
|
+
from .resources.audio_to_video import AudioToVideo
|
|
10
|
+
from .resources.human_identification import HumanIdentification
|
|
11
|
+
from .resources.subject_detection import SubjectDetection
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class OmnihumanClient:
|
|
15
|
+
"""OmniHuman audio-to-video and helper endpoint client.
|
|
16
|
+
|
|
17
|
+
Example::
|
|
18
|
+
|
|
19
|
+
client = OmnihumanClient(api_key="sk-...")
|
|
20
|
+
result = client.audio_to_video.run(
|
|
21
|
+
model="omnihuman-1.5",
|
|
22
|
+
source_image_url="https://cdn.runapi.ai/public/samples/portrait.jpg",
|
|
23
|
+
source_audio_url="https://cdn.runapi.ai/public/samples/voice.mp3",
|
|
24
|
+
)
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, api_key: Optional[str] = None, **options: Any) -> None:
|
|
28
|
+
resolved_api_key = resolve_api_key(api_key)
|
|
29
|
+
client_options = ClientOptions(api_key=resolved_api_key, **options)
|
|
30
|
+
http = client_options.http_client or HttpClient(client_options)
|
|
31
|
+
self.audio_to_video = AudioToVideo(http)
|
|
32
|
+
self.human_identification = HumanIdentification(http)
|
|
33
|
+
self.subject_detection = SubjectDetection(http)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
CONTRACT = {
|
|
2
|
+
"audio-to-video": {
|
|
3
|
+
"models": ["omnihuman-1.5"],
|
|
4
|
+
"fields_by_model": {
|
|
5
|
+
"omnihuman-1.5": {
|
|
6
|
+
"output_resolution": {
|
|
7
|
+
"enum": ["720p", "1080p"]
|
|
8
|
+
},
|
|
9
|
+
"prompt": {
|
|
10
|
+
"max": 1000,
|
|
11
|
+
"length": True
|
|
12
|
+
},
|
|
13
|
+
"seed": {
|
|
14
|
+
"type": "integer"
|
|
15
|
+
},
|
|
16
|
+
"source_audio_url": {
|
|
17
|
+
"required": True
|
|
18
|
+
},
|
|
19
|
+
"source_image_url": {
|
|
20
|
+
"required": True
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"human-identification": {
|
|
26
|
+
"models": ["omnihuman-1.5-human-identification"],
|
|
27
|
+
"fields_by_model": {
|
|
28
|
+
"omnihuman-1.5-human-identification": {
|
|
29
|
+
"source_image_url": {
|
|
30
|
+
"required": True
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"subject-detection": {
|
|
36
|
+
"models": ["omnihuman-1.5-subject-detection"],
|
|
37
|
+
"fields_by_model": {
|
|
38
|
+
"omnihuman-1.5-subject-detection": {
|
|
39
|
+
"source_image_url": {
|
|
40
|
+
"required": True
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from .audio_to_video import AudioToVideo
|
|
2
|
+
|
|
3
|
+
__all__ = ["AudioToVideo"]
|
|
4
|
+
from .audio_to_video import AudioToVideo
|
|
5
|
+
from .human_identification import HumanIdentification
|
|
6
|
+
from .subject_detection import SubjectDetection
|
|
7
|
+
|
|
8
|
+
__all__ = ["AudioToVideo", "HumanIdentification", "SubjectDetection"]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""OmniHuman audio-to-video resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource, RequestOptions
|
|
8
|
+
|
|
9
|
+
from ..contract_gen import CONTRACT
|
|
10
|
+
from ..types import (
|
|
11
|
+
AudioToVideoResponse,
|
|
12
|
+
CompletedAudioToVideoResponse,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
class AudioToVideo(Resource):
|
|
16
|
+
"""Generate a talking-head video from a source image and audio track."""
|
|
17
|
+
|
|
18
|
+
ENDPOINT = "/api/v1/omnihuman/audio_to_video"
|
|
19
|
+
|
|
20
|
+
RESPONSE_CLASS = AudioToVideoResponse
|
|
21
|
+
COMPLETED_RESPONSE_CLASS = CompletedAudioToVideoResponse
|
|
22
|
+
|
|
23
|
+
def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
24
|
+
"""Create a task and poll until it completes."""
|
|
25
|
+
task = self.create(options=options, **params)
|
|
26
|
+
return self._poll_until_complete(lambda: self.get(task.id, options=options))
|
|
27
|
+
|
|
28
|
+
def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
29
|
+
"""Create an audio-to-video task and return immediately with an ``id``."""
|
|
30
|
+
compacted = self._compact_params(params)
|
|
31
|
+
self._validate_params(compacted)
|
|
32
|
+
return self._request("post", self.ENDPOINT, body=compacted, options=options)
|
|
33
|
+
|
|
34
|
+
def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
|
|
35
|
+
"""Fetch the current status of an audio-to-video task."""
|
|
36
|
+
return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
|
|
37
|
+
|
|
38
|
+
def _validate_params(self, params: Dict[str, Any]) -> None:
|
|
39
|
+
self._validate_contract(CONTRACT["audio-to-video"], params)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""OmniHuman human-identification resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource, RequestOptions
|
|
8
|
+
|
|
9
|
+
from ..contract_gen import CONTRACT
|
|
10
|
+
from ..types import (
|
|
11
|
+
CompletedHumanIdentificationResponse,
|
|
12
|
+
HumanIdentificationResponse,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class HumanIdentification(Resource):
|
|
17
|
+
"""Identify human regions in a source image."""
|
|
18
|
+
|
|
19
|
+
ENDPOINT = "/api/v1/omnihuman/human_identification"
|
|
20
|
+
|
|
21
|
+
RESPONSE_CLASS = HumanIdentificationResponse
|
|
22
|
+
COMPLETED_RESPONSE_CLASS = CompletedHumanIdentificationResponse
|
|
23
|
+
|
|
24
|
+
def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
25
|
+
"""Create a task and poll until it completes."""
|
|
26
|
+
task = self.create(options=options, **params)
|
|
27
|
+
return self._poll_until_complete(lambda: self.get(task.id, options=options))
|
|
28
|
+
|
|
29
|
+
def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
30
|
+
"""Create a human-identification task and return immediately with an ``id``."""
|
|
31
|
+
compacted = self._compact_params(params)
|
|
32
|
+
self._validate_params(compacted)
|
|
33
|
+
return self._request("post", self.ENDPOINT, body=compacted, options=options)
|
|
34
|
+
|
|
35
|
+
def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
|
|
36
|
+
"""Fetch the current status of a human-identification task."""
|
|
37
|
+
return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
|
|
38
|
+
|
|
39
|
+
def _validate_params(self, params: Dict[str, Any]) -> None:
|
|
40
|
+
self._validate_contract(CONTRACT["human-identification"], params)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""OmniHuman subject-detection resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource, RequestOptions
|
|
8
|
+
|
|
9
|
+
from ..contract_gen import CONTRACT
|
|
10
|
+
from ..types import (
|
|
11
|
+
CompletedSubjectDetectionResponse,
|
|
12
|
+
SubjectDetectionResponse,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SubjectDetection(Resource):
|
|
17
|
+
"""Detect subject masks in a source image."""
|
|
18
|
+
|
|
19
|
+
ENDPOINT = "/api/v1/omnihuman/subject_detection"
|
|
20
|
+
|
|
21
|
+
RESPONSE_CLASS = SubjectDetectionResponse
|
|
22
|
+
COMPLETED_RESPONSE_CLASS = CompletedSubjectDetectionResponse
|
|
23
|
+
|
|
24
|
+
def run(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
25
|
+
"""Create a task and poll until it completes."""
|
|
26
|
+
task = self.create(options=options, **params)
|
|
27
|
+
return self._poll_until_complete(lambda: self.get(task.id, options=options))
|
|
28
|
+
|
|
29
|
+
def create(self, options: Optional[RequestOptions] = None, **params: Any) -> Any:
|
|
30
|
+
"""Create a subject-detection task and return immediately with an ``id``."""
|
|
31
|
+
compacted = self._compact_params(params)
|
|
32
|
+
self._validate_params(compacted)
|
|
33
|
+
return self._request("post", self.ENDPOINT, body=compacted, options=options)
|
|
34
|
+
|
|
35
|
+
def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
|
|
36
|
+
"""Fetch the current status of a subject-detection task."""
|
|
37
|
+
return self._request("get", f"{self.ENDPOINT}/{id}", options=options)
|
|
38
|
+
|
|
39
|
+
def _validate_params(self, params: Dict[str, Any]) -> None:
|
|
40
|
+
self._validate_contract(CONTRACT["subject-detection"], params)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""OmniHuman response models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from runapi.core import BaseModel, TaskResponse, optional, required
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Video(BaseModel):
|
|
9
|
+
url = optional(str)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Mask(BaseModel):
|
|
13
|
+
url = optional(str)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AudioToVideoResponse(TaskResponse):
|
|
17
|
+
"""Response for an audio-to-video task."""
|
|
18
|
+
|
|
19
|
+
id = required(str)
|
|
20
|
+
status = optional(str, enum=lambda: TaskResponse.Status.ALL)
|
|
21
|
+
videos = optional([lambda: Video])
|
|
22
|
+
error = optional(str)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CompletedAudioToVideoResponse(AudioToVideoResponse):
|
|
26
|
+
"""Returned by ``audio_to_video.run()`` once polling observes completion.
|
|
27
|
+
|
|
28
|
+
``videos`` is required so callers never have to null-check it on success.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
videos = required([lambda: Video])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class HumanIdentificationResponse(TaskResponse):
|
|
35
|
+
"""Response for a human-identification helper task."""
|
|
36
|
+
|
|
37
|
+
id = required(str)
|
|
38
|
+
status = optional(str, enum=lambda: TaskResponse.Status.ALL)
|
|
39
|
+
subject_status = optional(int)
|
|
40
|
+
error = optional(str)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class CompletedHumanIdentificationResponse(HumanIdentificationResponse):
|
|
44
|
+
"""Returned by ``human_identification.run()`` once polling observes completion."""
|
|
45
|
+
|
|
46
|
+
subject_status = required(int)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class SubjectDetectionResponse(TaskResponse):
|
|
50
|
+
"""Response for a subject-detection helper task."""
|
|
51
|
+
|
|
52
|
+
id = required(str)
|
|
53
|
+
status = optional(str, enum=lambda: TaskResponse.Status.ALL)
|
|
54
|
+
masks = optional([lambda: Mask])
|
|
55
|
+
error = optional(str)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CompletedSubjectDetectionResponse(SubjectDetectionResponse):
|
|
59
|
+
"""Returned by ``subject_detection.run()`` once polling observes completion."""
|
|
60
|
+
|
|
61
|
+
masks = required([lambda: Mask])
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runapi-omnihuman
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: RunAPI OmniHuman SDK for audio-to-video and image helper workflows in JavaScript, Python, Ruby, Go, Java, and PHP
|
|
5
|
+
Project-URL: Homepage, https://runapi.ai/models/omnihuman
|
|
6
|
+
Project-URL: Documentation, https://runapi.ai/docs#sdk-omnihuman
|
|
7
|
+
Project-URL: Source, https://github.com/runapi-ai/omnihuman-sdk
|
|
8
|
+
Project-URL: Issues, https://github.com/runapi-ai/omnihuman-sdk/issues
|
|
9
|
+
Author-email: RunAPI <contact@runapi.ai>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
Keywords: api,audio-to-video,golang,gradle,java,maven,omnihuman,omnihuman-api,python,ruby,runapi,runapi-ai,sdk,typescript,video-api,video-generation
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Requires-Dist: runapi-core>=0.1.4
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# OmniHuman Python SDK for RunAPI
|
|
17
|
+
|
|
18
|
+
The OmniHuman Python SDK is the language-specific package for OmniHuman on RunAPI. Use this package for audio-driven talking-head video generation, human identification, and subject-mask detection when your application needs request bodies, task status lookup, and consistent RunAPI errors in Python.
|
|
19
|
+
|
|
20
|
+
This README is the Python package guide inside the public `omnihuman-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/omnihuman; for API reference, use https://runapi.ai/docs#omnihuman; for SDK docs, use https://runapi.ai/docs#sdk-omnihuman.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install runapi-omnihuman
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from runapi.omnihuman import OmnihumanClient
|
|
32
|
+
|
|
33
|
+
client = OmnihumanClient() # reads RUNAPI_API_KEY, or pass api_key="sk-..."
|
|
34
|
+
|
|
35
|
+
task = client.audio_to_video.create(
|
|
36
|
+
model="omnihuman-1.5",
|
|
37
|
+
source_image_url="https://cdn.runapi.ai/public/samples/portrait.jpg",
|
|
38
|
+
source_audio_url="https://cdn.runapi.ai/public/samples/voice.mp3",
|
|
39
|
+
output_resolution="720p",
|
|
40
|
+
)
|
|
41
|
+
status = client.audio_to_video.get(task.id)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
|
|
45
|
+
|
|
46
|
+
RunAPI-generated file URLs are temporary. Download and store generated videos, masks, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
|
|
47
|
+
|
|
48
|
+
## Language notes
|
|
49
|
+
|
|
50
|
+
Pass parameters as keyword arguments and catch the `runapi.omnihuman` error classes when building video jobs or scripts. The available resources are `audio_to_video`, `human_identification`, and `subject_detection`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
51
|
+
|
|
52
|
+
## Links
|
|
53
|
+
|
|
54
|
+
- Model page: https://runapi.ai/models/omnihuman
|
|
55
|
+
- SDK docs: https://runapi.ai/docs#sdk-omnihuman
|
|
56
|
+
- Product docs: https://runapi.ai/docs#omnihuman
|
|
57
|
+
- Pricing and rate limits: https://runapi.ai/models/omnihuman/1.5
|
|
58
|
+
- Human identification: https://runapi.ai/models/omnihuman/1.5-human-identification
|
|
59
|
+
- Subject detection: https://runapi.ai/models/omnihuman/1.5-subject-detection
|
|
60
|
+
- Provider comparison: https://runapi.ai/providers/bytedance
|
|
61
|
+
- Full catalog: https://runapi.ai/models
|
|
62
|
+
- Repository: https://github.com/runapi-ai/omnihuman-sdk
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
runapi/omnihuman/__init__.py,sha256=NGa5t_9KSQT89Bi8hKX482Ojq5wyjfQmOPVuDLshQKg,469
|
|
2
|
+
runapi/omnihuman/client.py,sha256=ZYcG43knz61uXfzBYRO4NGVwOdhsM52RBL22VIBqMgg,1193
|
|
3
|
+
runapi/omnihuman/contract_gen.py,sha256=PVa5LfWEgnMAv-dlyBwBM0a-O87lhLx8uP0WwCgQQWI,1232
|
|
4
|
+
runapi/omnihuman/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
runapi/omnihuman/types.py,sha256=5eEZvis0WRfEvojBi8fg7LxDg_sgbQiteXYw_dGqfdQ,1653
|
|
6
|
+
runapi/omnihuman/resources/__init__.py,sha256=nPt_lgsDsYZoZvY0x3MdmfmD2D9Ktxdy45kn3vOcbvc,283
|
|
7
|
+
runapi/omnihuman/resources/audio_to_video.py,sha256=oCBE7mgnh2WhVyrRJkSx1y-YerPOyIQ5fWj53l2o_HI,1532
|
|
8
|
+
runapi/omnihuman/resources/human_identification.py,sha256=5Fc3937ySny63JcGIRNzhy8YA_hgjcAPl1qbPFehogk,1571
|
|
9
|
+
runapi/omnihuman/resources/subject_detection.py,sha256=tn13oG8hd42LUzZR8ArCf7WObDWnIPgwNUQAp1LoIgI,1539
|
|
10
|
+
runapi_omnihuman-0.1.1.dist-info/METADATA,sha256=GHp3wfflDRdC6w7ebwybCwduhNCq5wglUJgWFpHgnQE,3326
|
|
11
|
+
runapi_omnihuman-0.1.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
12
|
+
runapi_omnihuman-0.1.1.dist-info/RECORD,,
|