-
Notifications
You must be signed in to change notification settings - Fork 164
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
Lifelong learning supporting non-structure #352
base: main
Are you sure you want to change the base?
Changes from all commits
98a4047
e5d2291
53e5ae4
88827ef
3ed85a0
572f4e3
e12ccac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from basemodel import val_args | ||
from utils.metrics import Evaluator | ||
from tqdm import tqdm | ||
from dataloaders import make_data_loader | ||
from sedna.common.class_factory import ClassType, ClassFactory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note the order of import |
||
|
||
__all__ = ('accuracy') | ||
|
||
@ClassFactory.register(ClassType.GENERAL) | ||
def accuracy(y_true, y_pred, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Common keyword. Use alias while register. |
||
args = val_args() | ||
_, _, test_loader, num_class = make_data_loader(args, test_data=y_true) | ||
evaluator = Evaluator(num_class) | ||
|
||
tbar = tqdm(test_loader, desc='\r') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useless |
||
for i, (sample, img_path) in enumerate(tbar): | ||
if args.depth: | ||
image, depth, target = sample['image'], sample['depth'], sample['label'] | ||
else: | ||
image, target = sample['image'], sample['label'] | ||
if args.cuda: | ||
image, target = image.cuda(), target.cuda() | ||
if args.depth: | ||
depth = depth.cuda() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check whether the device supports GPU. |
||
|
||
target[target > evaluator.num_class-1] = 255 | ||
target = target.cpu().numpy() | ||
# Add batch sample into evaluator | ||
evaluator.add_batch(target, y_pred[i]) | ||
|
||
# Test during the training | ||
# Acc = evaluator.Pixel_Accuracy() | ||
CPA = evaluator.Pixel_Accuracy_Class() | ||
mIoU = evaluator.Mean_Intersection_over_Union() | ||
FWIoU = evaluator.Frequency_Weighted_Intersection_over_Union() | ||
|
||
print("CPA:{}, mIoU:{}, fwIoU: {}".format(CPA, mIoU, FWIoU)) | ||
return CPA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import of the relative path should be adjusted.