Giter VIP home page Giter VIP logo

Comments (5)

ankurguria avatar ankurguria commented on June 30, 2024

@SurajDonthi where exactly is the output of the testing stored?

from multi-camera-person-re-identification.

SurajDonthi avatar SurajDonthi commented on June 30, 2024

@ankurguria you'll need 2 attributes as input:

  1. Image/Frame
  2. Timestamp formatted in either Market-1501 or Duke MTMC format.
    You can create a Dataset from this.
# INPUTS
query_image: torch.Tensor()
query_cam_id: torch.Tensor()
query_frame: torch.Tensor()

class Dataset(...):
    def __init__(self, ...):
    ...
    self.gallery_images: torch.Tensor()
    self.labels: torch.Tensor()
    self.gallery_cam_ids: torch.Tensor()
    self.gallery_frames: torch.Tensor()
    ...
    
    def __getitem__(self, idx):
    # Preprocessing
    ...
    return processed_gallery_img[idx], self.gallery_cam_ids[idx], self.gallery_frames[idx]

dataset = Dataset(...)
dataloader(dataset, shuffle=False, ...)

To query on a single image against a gallery,

  1. You'll need to first compute the feature vectors self(x, training=False) of all gallery images (pass through CNN) & also collect their respective cam_id & frame/timestamp.
# Compute Feature Vector of Query Image
query_feature = self(query_image)

# Compute Feature Vector of all Gallery Images
gallery_features = torch.Tensor()
gallery_cam_ids = torch.Tensor()
gallery_frames = torch.Tensor()

for gallery_image, cam_id, frame in dataloader:
    feature_sum = self(gallery_image, training=False)
    flipped_image = fliplr(gallery_image)
    feature_sum += self(flipped_image, training=False)

    gallery_features = torch.cat([gallery_features, feature_sum])
    gallery_cam_ids = torch.cat([gallery_cam_ids, cam_id])
    gallery_frames = torch.cat([gallery_frames, frame])
  1. With these two attributes for both your query image & all the gallery images, you can calculate the joint_scores() given the Spatio-Temporal Distribution.
scores = joint_scores(
    query_feature, 
    query_cam_id, 
    query_frame, 
    gallery_features, 
    gallery_cam_ids, 
    gallery_frames, 
    spatio_tempotal_distribution
)

# Optional
reranked_scores = re_ranking(scores)
  1. So the one with the highest joint score is the predicted gallery image/person_id.
gallery_image_idx = np.argmax(scores)     # np.argmax(reranked_scores)
person_id = dataset.labels[gallery_image_idx]

Note: Functions to compute Spatio-Temporal Distribution(smooth_st_distribution), Joint Score(joint_score) & Re-ranking(re_ranking) are available in metrics.py.

I hope this detailed explanation is helpful.

from multi-camera-person-re-identification.

SurajDonthi avatar SurajDonthi commented on June 30, 2024

@SurajDonthi where exactly is the output of the testing stored?

Currently, only the metrics are stored. However, feel free to create a pull request to add storing of the test outputs.

from multi-camera-person-re-identification.

ankurguria avatar ankurguria commented on June 30, 2024

@SurajDonthi thanks a lot for the detailed explanation. I understood the code.

I did try running this on Kaggle notebooks using the demo.ipynb. There are some output visualizations when I "commit and save it" on Kaggle. There must be some code already in the repo doing the visualization. But I wasn't able to find them. Could you please help me in pointing that chunk of code?

from multi-camera-person-re-identification.

SurajDonthi avatar SurajDonthi commented on June 30, 2024

@ankurguria, what you are looking for is engine.py. The answer to all your questions lie in this file.

With regard to visualization, I think you're referring to the Spatio-Temporal Distribution. You can find it here:

fig = plot_distributions(self.trainer.datamodule.st_distribution)
.

Please feel free to contribute any additional visualizations.

from multi-camera-person-re-identification.

Related Issues (15)

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.