Git Product home page Git Product logo

Comments (2)

gasharper avatar gasharper commented on June 2, 2024

The inference process is the same as the evaluation process.
You can refer to the following code in trian.py:

PyramidFlow/train.py

Lines 59 to 80 in c463b1c

# val for template
flow.eval()
feat_sum, cnt = [0 for _ in range(num_layer)], 0
for val_dict in val_loader:
image = val_dict['images'].to(device)
with torch.no_grad():
pyramid2= flow(image)
cnt += 1
feat_sum = [p0+p for p0, p in zip(feat_sum, pyramid2)]
feat_mean = [p/cnt for p in feat_sum]
# test
flow.eval()
diff_list, labels_list = [], []
for test_dict in test_loader:
image, labels = test_dict['images'].to(device), test_dict['labels']
with torch.no_grad():
pyramid2 = flow(image)
pyramid_diff = [(feat2 - template).abs() for feat2, template in zip(pyramid2, feat_mean)]
diff = flow.pyramid.compose_pyramid(pyramid_diff).mean(1, keepdim=True)# b,1,h,w
diff_list.append(diff.cpu())
labels_list.append(labels.cpu()==1)# b,1,h,w

from pyramidflow.

pribadihcr avatar pribadihcr commented on June 2, 2024

I think we need the inference demo, start from how to load the trained model and infer the test image.

from pyramidflow.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.