|
We leverage it to improve our prompt |
|
a rabbit wearing a space suit: |
|
thon |
|
from transformers import HfAgent |
|
agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=[tool]) |
|
agent.run("Generate an image of the prompt after improving it.", prompt="A rabbit wearing a space suit") |
|
|
|
The model adequately leverages the tool: |
|
``text |
|
==Explanation from the agent== |
|
I will use the following tools:StableDiffusionPromptGeneratorto improve the prompt, thenimage_generator` to generate an image according to the improved prompt. |
|
==Code generated by the agent== |
|
improved_prompt = StableDiffusionPromptGenerator(prompt) |
|
print(f"The improved prompt is {improved_prompt}.") |
|
image = image_generator(improved_prompt) |
|
|
|
Before finally generating the image: |
|
|
|
gradio-tools requires textual inputs and outputs, even when working with different modalities. |