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

AttributeError: 'list' object has no attribute 'astype' #63

Open
royzhou007 opened this issue Apr 27, 2023 · 4 comments
Open

AttributeError: 'list' object has no attribute 'astype' #63

royzhou007 opened this issue Apr 27, 2023 · 4 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers question Further information is requested

Comments

@royzhou007
Copy link

results = SegManualMaskPredictor().image_predict(
source="C:\software\sam_checkpoint\3515.jpg",
model_type="vit_h", # vit_l, vit_h, vit_b
input_point=[[548, 1031], [1121, 769]],
input_label=[0, 1],
input_box=[229, 684, 800, 800], # or [[100, 100, 200, 200], [100, 100, 200, 200]]
multimask_output=False,
random_color=False,
#output_path="C:\software\sam_checkpoint\output2.jpg",
show=False,
save=True,
)

======================
AttributeError Traceback (most recent call last)
Cell In[43], line 1
----> 1 results = SegManualMaskPredictor().image_predict(
2 source="C:\software\sam_checkpoint\3515.jpg",
3 model_type="vit_h", # vit_l, vit_h, vit_b
4 input_point=[[548, 1031], [1121, 769]],
5 input_label=[0, 1],
6 input_box=[229, 684, 800, 800], # or [[100, 100, 200, 200], [100, 100, 200, 200]]
7 multimask_output=False,
8 random_color=False,
9 #output_path="C:\software\sam_checkpoint\output2.jpg",
10 show=False,
11 save=True,
12 )

File ~\anaconda3\lib\site-packages\metaseg\mask_predictor.py:175, in SegManualMaskPredictor.image_predict(self, source, model_type, input_box, input_point, input_label, multimask_output, output_path, random_color, show, save)
172 elif type(input_box[0]) == int:
173 input_boxes = np.array(input_box)[None, :]
--> 175 masks, _, _ = predictor.predict(
176 point_coords=input_point,
177 point_labels=input_label,
178 box=input_boxes,
179 multimask_output=multimask_output,
180 )
181 mask_image = load_mask(masks, random_color)
182 image = load_box(input_box, image)

File ~\anaconda3\lib\site-packages\metaseg\generator\predictor.py:139, in SamPredictor.predict(self, point_coords, point_labels, box, mask_input, multimask_output, return_logits)
137 if point_coords is not None:
138 assert point_labels is not None, "point_labels must be supplied if point_coords is supplied."
--> 139 point_coords = self.transform.apply_coords(point_coords, self.original_size)
140 coords_torch = torch.as_tensor(point_coords, dtype=torch.float, device=self.device)
141 labels_torch = torch.as_tensor(point_labels, dtype=torch.int, device=self.device)

File ~\anaconda3\lib\site-packages\metaseg\utils\transforms.py:40, in ResizeLongestSide.apply_coords(self, coords, original_size)
38 old_h, old_w = original_size
39 new_h, new_w = self.get_preprocess_shape(original_size[0], original_size[1], self.target_length)
---> 40 coords = deepcopy(coords).astype(float)
41 coords[..., 0] = coords[..., 0] * (new_w / old_w)
42 coords[..., 1] = coords[..., 1] * (new_h / old_h)

AttributeError: 'list' object has no attribute 'astype'

@kadirnar kadirnar self-assigned this Apr 27, 2023
@kadirnar kadirnar added bug Something isn't working good first issue Good for newcomers question Further information is requested labels Apr 27, 2023
@kadirnar
Copy link
Owner

Can you share the picture?

@royzhou007
Copy link
Author

3515

@RugnirViking
Copy link

RugnirViking commented May 10, 2023

Hi there, I am also getting this issue. I also tried not defining the input_box, and it instead gives 'NoneType' object is not subscriptable (the default value is "none" but there is no check for this).

Similarly, when using the manualmaskpredictor for video with the example provided in the readme, it errors because input_box is None

@Bardhitoo
Copy link

Bardhitoo commented Jun 9, 2023

@royzhou007

Change this line to: coords = np.array(deepcopy(coords), dtype=np.float32)

That resolved my issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants