Git Product home page Git Product logo

Comments (2)

wangguangyuan avatar wangguangyuan commented on May 22, 2024 1

你好你好你说的这个功能我之前参考cluster-contrast-reid/clustercontrast/evaluators.py 评测代码实现一版,希望对你有帮助。

`class Evaluator(object):
def init(self, model):
super(Evaluator, self).init()
self.model = model

  def evaluate(self, data_loader, query, gallery, cmc_flag=False, rerank=False):
      features, _ = extract_features(self.model, data_loader)
      distmat, query_features, gallery_features = pairwise_distance(features, query, gallery)
      x = [f for f, _, _ in query]
      y = [f for f, _, _ in gallery]
      
      indices = np.argsort(distmat, axis=1)
      for i, q_f_name in enumerate(x):
          # q_f_name = query[i][0]
          root_path = './query/spcl/{}'.format(i)
          if not os.path.exists(root_path):
              os.makedirs(root_path)
          q_path = os.path.join(root_path, 'q')
          if not os.path.exists(q_path):
              os.makedirs(q_path)
          g_path = os.path.join(root_path, 'g')
          if not os.path.exists(g_path):
              os.makedirs(g_path)
          shutil.copy(q_f_name, os.path.join(q_path, os.path.basename(q_f_name)))
      
          for j, index in enumerate(indices[i][:50]):
              g_f_name = y[index]
              g_name = '{}'.format(j) + '_' + os.path.basename(g_f_name)
              g_name = os.path.join(g_path, g_name)
              shutil.copy(g_f_name, g_name)

from cluster-contrast-reid.

opentld avatar opentld commented on May 22, 2024

你好你好你说的这个功能我之前参考cluster-contrast-reid/clustercontrast/evaluators.py 评测代码实现一版,希望对你有帮助。

`class Evaluator(object):
def init(self, model):
super(Evaluator, self).init()
self.model = model

  def evaluate(self, data_loader, query, gallery, cmc_flag=False, rerank=False):
      features, _ = extract_features(self.model, data_loader)
      distmat, query_features, gallery_features = pairwise_distance(features, query, gallery)
      x = [f for f, _, _ in query]
      y = [f for f, _, _ in gallery]
      
      indices = np.argsort(distmat, axis=1)
      for i, q_f_name in enumerate(x):
          # q_f_name = query[i][0]
          root_path = './query/spcl/{}'.format(i)
          if not os.path.exists(root_path):
              os.makedirs(root_path)
          q_path = os.path.join(root_path, 'q')
          if not os.path.exists(q_path):
              os.makedirs(q_path)
          g_path = os.path.join(root_path, 'g')
          if not os.path.exists(g_path):
              os.makedirs(g_path)
          shutil.copy(q_f_name, os.path.join(q_path, os.path.basename(q_f_name)))
      
          for j, index in enumerate(indices[i][:50]):
              g_f_name = y[index]
              g_name = '{}'.format(j) + '_' + os.path.basename(g_f_name)
              g_name = os.path.join(g_path, g_name)
              shutil.copy(g_f_name, g_name)

perfect!thank you very much !

from cluster-contrast-reid.

Related Issues (20)

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.