ME-GraphAU icon indicating copy to clipboard operation
ME-GraphAU copied to clipboard

Unable to execute OpenGraphAU

Open TalBarami opened this issue 11 months ago • 2 comments

Hey folks, Thanks for this impressive work. I couldn't execute the OpenGraphAU demo.py file, as the config file of the hybrid dataset is not included. I only need the inference phase on my dataset using your pre-trained model. Could you please elaborate on how to achieve it?

I really appreciate any help you can provide. Tal

TalBarami avatar Jul 30 '23 18:07 TalBarami

Hello, I'm currently facing exactly the same issue right now for the OpenGraphAU. did you solve the problem?

regards, enes.

altunenes avatar Feb 17 '24 13:02 altunenes

Okay I have fixed the problem, if anyone wants to run the demo.py file, here are the simple steps: :-) the problem is mostly about the yaml.load() fn. This function requires specifying a Loader, which is a requirement in newer versions of PyYAML for some reasons.

To fix this issue, we should modify the yaml.load(f) calls in the conf.py for example: change this

#previous:
datasets_cfg = yaml.load(f)

with this


# Updated line to use safe_load:
datasets_cfg = yaml.safe_load(f)

more precisely: (in conf.py)

def get_config():
    # args from argparser
    cfg = parser2dict()
    if cfg.dataset == 'BP4D':
        with open('config/BP4D_config.yaml', 'r') as f:
            datasets_cfg = yaml.safe_load(f)
            datasets_cfg = edict(datasets_cfg)

    elif cfg.dataset == 'DISFA':
        with open('config/DISFA_config.yaml', 'r') as f:
            datasets_cfg = yaml.safe_load(f)
            datasets_cfg = edict(datasets_cfg)

    elif cfg.dataset == 'hybrid':
        with open('config/hybrid_config.yaml', 'r') as f:
            datasets_cfg = yaml.safe_load(f)
            datasets_cfg = edict(datasets_cfg)
    else:
        raise Exception("Unknown Datasets:", cfg.dataset)

    cfg.update(datasets_cfg)
    return cfg

also you have to download following models and put them inside of the "checkpoints " (under the opengraph folder, Create it yourself (like in the original ME-GraphAU) as it is not currently provided.))

1- resnet50-19c8e357.pth 2- OpenGprahAU-ResNet50_first_stage.pth

so this command finally works on me: :-)

!python demo.py --arc resnet50 --stage 1 --exp-name demo --resume OpenGprahAU-ResNet50_first_stage.pth --input demo_imgs/1014.jpg --draw_text

altunenes avatar Feb 18 '24 17:02 altunenes