ImageToScribble¶
- class agentlego.tools.ImageToScribble(device='cuda', toolmeta=None)[source]
A tool to convert image to a scribble sketch.
Default Tool Meta¶
name: ImageToScribble
description: This tool can generate a sketch scribble of an image.
inputs:
image (ImageIO)
outputs:
ImageIO
Examples¶
Use the tool directly (without agent)
from agentlego.apis import load_tool
# load tool
tool = load_tool('ImageToScribble', device='cuda')
# apply tool
scribble = tool('examples/demo.png')
print(scribble)
With Lagent
from lagent import ReAct, GPTAPI, ActionExecutor
from agentlego.apis import load_tool
# load tools and build agent
# please set `OPENAI_API_KEY` in your environment variable.
tool = load_tool('ImageToScribble', device='cuda').to_lagent()
agent = ReAct(GPTAPI(temperature=0.), action_executor=ActionExecutor([tool]))
# agent running with the tool.
img_path = 'examples/demo.png'
ret = agent.chat(f'Please draw the scribble sketch of the image `{img_path}`')
for step in ret.inner_steps[1:]:
print('------')
print(step['content'])
Set up¶
Before using the tool, please confirm you have installed the related dependencies by the below commands.
pip install -U controlnet_aux
Reference¶
The tool use controlnet_aux to generate an auxiliary
scribble sketch that can be used in the ControlNet.