Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

evaluate.py 700 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  1. from mrcnn.model import load_image_gt
  2. from mrcnn.model import mold_image
  3. from mrcnn.utils import compute_ap
  4. import numpy as np
  5. def evaluate_model(dataset, model, cfg):
  6. APs = list()
  7. for image_id in dataset.image_ids:
  8. image, _, gt_class_id, gt_bbox, gt_mask = load_image_gt(dataset, cfg, image_id)
  9. scaled_image = mold_image(image, cfg)
  10. sample = np.expand_dims(scaled_image, 0)
  11. yhat = model.detect(sample, verbose = 0)
  12. r = yhat[0]
  13. AP, _, _, _ = compute_ap(
  14. gt_bbox, gt_class_id, gt_mask,
  15. r['rois'], r['class_ids'], r['scores'], r['masks'])
  16. APs.append(AP)
  17. meanAP = np.mean(APs)
  18. return meanAP
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...