Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VideoDevice to control camera for vision input📷 #59

Merged
merged 2 commits into from
Jun 8, 2024

Conversation

uezo
Copy link
Owner

@uezo uezo commented Jun 8, 2024

Usage

import io
import pyautogui
from aiavatar.device.video import VideoDevice

default_camera = VideoDevice()

# get_image that supports multiple source
async def get_image(source) -> bytes:
    if source == "camera":
        return await default_camera.capture_image()
    else:
        buffered = io.BytesIO()
        image = pyautogui.screenshot(region=(0, 0, 1280, 720))
        image.save(buffered, format="PNG")
        return buffered.getvalue()

# ChatGPT Processor with Vision
chat_processor_gpt = ChatGPTProcessor(
    api_key=OPENAI_API_KEY,
    model="gpt-4o",
    system_message_content=PROMPT,
    use_vision=True
)

# Set `get_image`
chat_processor_gpt.get_image = get_image

uezo added 2 commits June 8, 2024 17:46
Usage

```python
import io
import pyautogui
from aiavatar.device.video import VideoDevice

default_camera = VideoDevice()

async def get_image(source) -> bytes:
    if source == "camera":
        return await default_camera.capture_image()
    else:
        buffered = io.BytesIO()
        image = pyautogui.screenshot(region=(0, 0, 1280, 720))
        image.save(buffered, format="PNG")
        return buffered.getvalue()

# ChatGPT Processor with Vision
chat_processor_gpt = ChatGPTProcessor(
    api_key=OPENAI_API_KEY,
    model="gpt-4o",
    system_message_content=PROMPT,
    use_vision=True
)
chat_processor_gpt.get_image = get_image
```
@uezo uezo merged commit 0751ab8 into main Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant