Giter Site home page Giter Site logo

zero shot classification results about gloria HOT 4 OPEN

gefend avatar gefend commented on August 10, 2024
zero shot classification results

from gloria.

Comments (4)

marshuang80 avatar marshuang80 commented on August 10, 2024

To help you debug this, can you please provide the following information?

  • What dataset are you using?
  • How are you preprocessing the data?
  • What are your classification tasks?
  • How are you generating the class prompts?

from gloria.

gefend avatar gefend commented on August 10, 2024
  1. I'm using the Chexpert 5X200 dataset
  2. I have used the "Zeroshot classification for CheXpert5x200" script from your Readme file without additional preproccesing.
    The only change I made in the "Zeroshot classification for CheXpert5x200" was the generation of the chexpert 5X200 data set using your function preprocess_chexpert_5X200_data from gloria.datasets.preprocess_datasets .
  3. The classification task is the same as your classification task on chexpert 5X200, classification of each image into on of the 5 classes.
  4. As part of using your script I am generating the class_prompts using your function generate_chexpert_class_prompts
    Thank you for your answer!

from gloria.

marshuang80 avatar marshuang80 commented on August 10, 2024

Got it, thanks for the info. May I ask how you are computing the results? Using different random seeds I was still able to get an accuracy of 60+

labels = df[gloria.constants.CHEXPERT_COMPETITION_TASKS].to_numpy().argmax(axis=1)
pred = similarities[gloria.constants.CHEXPERT_COMPETITION_TASKS].to_numpy().argmax(axis=1)
acc = len(labels[labels == pred]) / len(labels)
print(acc) # 0.607

from gloria.

gefend avatar gefend commented on August 10, 2024

The following is the code I used, I tried to replace the results calculation to the one you suggested but I get the same results. The only thing that I think I'm doing different than you is that I take only 200 images every run because of my GPU memory capacity.

import torch
import gloria
import pandas as pd
from gloria.datasets.preprocess_datasets import preprocess_chexpert_5x200_data

df = preprocess_chexpert_5x200_data()
df = df[0:200]
# load model
device = "cuda" if torch.cuda.is_available() else "cpu"
gloria_model = gloria.load_gloria(device=device)

cls_prompts = gloria.generate_chexpert_class_prompts()

# process input images and class prompts
processed_txt = gloria_model.process_class_prompts(cls_prompts, device)
processed_imgs = gloria_model.process_img(df['Path'].tolist(), device)

# zero-shot classification on 1000 images
similarities = gloria.zero_shot_classification(
    gloria_model, processed_imgs, processed_txt)

labels = df[gloria.constants.CHEXPERT_COMPETITION_TASKS].to_numpy().argmax(axis=1)
pred = similarities[gloria.constants.CHEXPERT_COMPETITION_TASKS].to_numpy().argmax(axis=1)
acc = len(labels[labels == pred]) / len(labels) #0.17

from gloria.

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.