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

代码错误 #29

Open
kx-kexi opened this issue Jun 20, 2024 · 1 comment
Open

代码错误 #29

kx-kexi opened this issue Jun 20, 2024 · 1 comment

Comments

@kx-kexi
Copy link

kx-kexi commented Jun 20, 2024

in_coordinate, out_coordinate = det(image, "icon", groundingdino_model)
这里返回两个值,但是方法只返回了一个值,是不是有错误啊,代码在Mobile-Agent/run.py 的149行
def det(input_image_path, caption, groundingdino_model, box_threshold=0.05, text_threshold=0.5):
image = Image.open(input_image_path)
size = image.size

caption = caption.lower()
caption = caption.strip()
if not caption.endswith('.'):
    caption = caption + '.'

inputs = {
    'IMAGE_PATH': input_image_path,
    'TEXT_PROMPT': caption,
    'BOX_TRESHOLD': box_threshold,
    'TEXT_TRESHOLD': text_threshold
}

result = groundingdino_model(inputs)
print(result)
boxes_filt = result['boxes']

H, W = size[1], size[0]
for i in range(boxes_filt.size(0)):
    boxes_filt[i] = boxes_filt[i] * torch.Tensor([W, H, W, H])
    boxes_filt[i][:2] -= boxes_filt[i][2:] / 2
    boxes_filt[i][2:] += boxes_filt[i][:2]

boxes_filt = boxes_filt.cpu().int().tolist()
filtered_boxes = remove_boxes(boxes_filt, size)  # [:9]
coordinates = []
for box in filtered_boxes:
    coordinates.append([box[0], box[1], box[2], box[3]])

return coordinates
junyangwang0410 added a commit that referenced this issue Jun 20, 2024
@junyangwang0410
Copy link
Collaborator

in_coordinate, out_coordinate = det(image, "icon", groundingdino_model) 这里返回两个值,但是方法只返回了一个值,是不是有错误啊,代码在Mobile-Agent/run.py 的149行 def det(input_image_path, caption, groundingdino_model, box_threshold=0.05, text_threshold=0.5): image = Image.open(input_image_path) size = image.size

caption = caption.lower()
caption = caption.strip()
if not caption.endswith('.'):
    caption = caption + '.'

inputs = {
    'IMAGE_PATH': input_image_path,
    'TEXT_PROMPT': caption,
    'BOX_TRESHOLD': box_threshold,
    'TEXT_TRESHOLD': text_threshold
}

result = groundingdino_model(inputs)
print(result)
boxes_filt = result['boxes']

H, W = size[1], size[0]
for i in range(boxes_filt.size(0)):
    boxes_filt[i] = boxes_filt[i] * torch.Tensor([W, H, W, H])
    boxes_filt[i][:2] -= boxes_filt[i][2:] / 2
    boxes_filt[i][2:] += boxes_filt[i][:2]

boxes_filt = boxes_filt.cpu().int().tolist()
filtered_boxes = remove_boxes(boxes_filt, size)  # [:9]
coordinates = []
for box in filtered_boxes:
    coordinates.append([box[0], box[1], box[2], box[3]])

return coordinates

感谢纠正,我们不小心混淆了v1和v2的图标检测流程,现在已经修复。

junyangwang0410 added a commit that referenced this issue Jun 21, 2024
junyangwang0410 added a commit that referenced this issue Jun 21, 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

No branches or pull requests

2 participants