File size: 819 Bytes
111afa2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from smolagents import AgentImage, Tool


class ImageResizeTool(Tool):
    name = "image_resize"
    description = """
        Resize the image to a smaller size.
        The image is a PIL image.
        The output is the resized image.
    """

    inputs = {
        "image": {
            "type": "image",
            "description": "The image to resize.",
        },
        "width": {
            "type": "number",
            "description": "The width to resize the image to.",
        },
        "height": {
            "type": "number",
            "description": "The height to resize the image to.",
        },
    }
    output_type = "image"

    def __init__(self):
        super().__init__()

    def forward(self, image: AgentImage, width: int, height: int):
        return image.resize((width, height))