Update tools.py
Browse files
tools.py
CHANGED
|
@@ -121,10 +121,11 @@ class image_interpreter(Tool):
|
|
| 121 |
description = "Allows you to convert an image to text (the function will describe the image)."
|
| 122 |
inputs = {
|
| 123 |
'image': {"type": "image", "description": "The image of interest, png format or jpeg (must be the local path of the image)"},
|
|
|
|
| 124 |
}
|
| 125 |
output_type = "string"
|
| 126 |
|
| 127 |
-
def forward(self, image):
|
| 128 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 129 |
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 130 |
"Qwen/Qwen2-VL-7B-Instruct", torch_dtype="auto", device_map="auto"
|
|
@@ -136,7 +137,7 @@ class image_interpreter(Tool):
|
|
| 136 |
"role": "user",
|
| 137 |
"content": [
|
| 138 |
{"type": "image", "image": Image.open(image).convert("RGB")},
|
| 139 |
-
{"type": "text", "text": "describe this image, with as much details as you can"},
|
| 140 |
],
|
| 141 |
}
|
| 142 |
]
|
|
|
|
| 121 |
description = "Allows you to convert an image to text (the function will describe the image)."
|
| 122 |
inputs = {
|
| 123 |
'image': {"type": "image", "description": "The image of interest, png format or jpeg (must be the local path of the image)"},
|
| 124 |
+
'prompt': {"type": "string", "description": "The function returns a description of the image, but you can request specific details with this prompt to ensure they are included in the description."},
|
| 125 |
}
|
| 126 |
output_type = "string"
|
| 127 |
|
| 128 |
+
def forward(self, image, prompt):
|
| 129 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 130 |
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 131 |
"Qwen/Qwen2-VL-7B-Instruct", torch_dtype="auto", device_map="auto"
|
|
|
|
| 137 |
"role": "user",
|
| 138 |
"content": [
|
| 139 |
{"type": "image", "image": Image.open(image).convert("RGB")},
|
| 140 |
+
{"type": "text", "text": "describe this image, with as much details as you can" + str(prompt)},
|
| 141 |
],
|
| 142 |
}
|
| 143 |
]
|