Comments (1)
Another similiar problem occurs when I directly use images in size 512 for inference.
codes from baseline that I use:
detect_thresh = 0.3
nms_thresh = 0.5
size = 1024
nr = []
pos = []
for image_id, (test_image, emp_label) in enumerate(learn.data.test_ds):
#mean, std = learn.data.stats
pos.append([0, 0, 0, 0])
nr.append(0)
image_ori = test_image
# ori_shape = image_ori.shape[:2]
# image = cv2.resize(image_ori, (size, size))
# image = pil2tensor(image / 255., np.float32).cuda()
#image = transforms.Normalize(mean, std)(image)
image = test_image.resize(1024).data.cuda()
# class_pred_batch, bbox_pred_batch, _ = learn.model(image[None, :, :, :])
class_pred_batch, bbox_pred_batch, _ = learn.model(image[None, :])
for clas_pred, bbox_pred in zip(class_pred_batch, bbox_pred_batch):
bbox_pred, scores, preds = process_output(clas_pred, bbox_pred, anchors, detect_thresh)
if bbox_pred is not None:
to_keep = nms(bbox_pred, scores, nms_thresh)
bbox_pred, preds, scores = bbox_pred[to_keep].cpu(), preds[to_keep].cpu(), scores[to_keep].cpu()
t_sz = torch.Tensor(ori_shape)[None].float()
bbox_pred = rescale_box(bbox_pred, t_sz)
temp_pos = [0, 0, 0, 0]
for id, box in enumerate(bbox_pred[:2]):
x = to_np(box[0] + box[2] / 2)
y = to_np(box[1] + box[3] / 2)
if id == 0:
temp_pos[ :2] = x,y
nr[image_id] = 1
else:
temp_pos[2: ] = x, y
nr[image_id] = 2
output:
RuntimeError Traceback (most recent call last)
<ipython-input-65-883a98e5b6df> in <module>
27
28 for clas_pred, bbox_pred in zip(class_pred_batch, bbox_pred_batch):
---> 29 bbox_pred, scores, preds = process_output(clas_pred, bbox_pred, anchors, detect_thresh)
30
31 if bbox_pred is not None:
D:\ProgramFile\anaconda\envs\ai\lib\site-packages\object_detection_fastai\helper\object_detection_helper.py in process_output(clas_pred, bbox_pred, anchors, detect_thresh)
227
228 def process_output(clas_pred, bbox_pred, anchors, detect_thresh=0.25):
--> 229 bbox_pred = activ_to_bbox(bbox_pred, anchors.to(clas_pred.device))
230 clas_pred = torch.sigmoid(clas_pred)
231
D:\ProgramFile\anaconda\envs\ai\lib\site-packages\object_detection_fastai\helper\object_detection_helper.py in activ_to_bbox(acts, anchors, flatten)
74 if flatten:
75 acts.mul_(acts.new_tensor([[0.1, 0.1, 0.2, 0.2]]))
---> 76 centers = anchors[...,2:] * acts[...,:2] + anchors[...,:2]
77 sizes = anchors[...,2:] * torch.exp(acts[...,2:])
78 return torch.cat([centers, sizes], -1)
RuntimeError: The size of tensor a (24480) must match the size of tensor b (24192) at non-singleton dimension 0
Two numbers don't match, same as above - 24480 (the number of anchors) and 24192 (what is this about). I guess this has something to do with the resizing as both those problems occur after resizing but I really can't come up with anything to fix this.
Also I'm using GPU for training.
from objectdetection.
Related Issues (20)
- No module name BoundingBox HOT 1
- size problem
- Inference Error HOT 8
- Fastai V2
- Anchors are totally wrong HOT 2
- In examples, incorrect anchors preview
- Exception: It's not possible to apply those transforms to your dataset HOT 5
- Validation scores
- Prediction Example HOT 2
- Migrating ObjectDetection to FastAIv2 HOT 2
- Error in NMS function
- any script to get prediction on single .scn file with coco .json annotations
- How to change number of classes for already trained retinanet model HOT 3
- How can i get the predicted classes from my retinanet model detection over the images.
- How to use fastai v2 for this library HOT 1
- How to save the image patches that are created from databunch method?
- Requesting object detection for fastai v2 HOT 1
- mAP seems to be [email protected] not mAP value
- Any script to train the model ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objectdetection.