thuiar / MMSA

MMSA is a unified framework for Multimodal Sentiment Analysis.
MIT License
642 stars 104 forks source link

Problems with relative imports #35

Closed BastianBN closed 2 years ago

BastianBN commented 2 years ago

Hi,

I'm having some problems running MMSA, I've ran pip install . and it worked, but when I try to run the file by doing python3 src/MMSA/run.py or even python3 src/MMSA, I respectively get the following errors :

Traceback (most recent call last):
  File "run.py", line 18, in <module>
    from .config import get_config_regression, get_config_tune
ImportError: attempted relative import with no known parent package

or

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/work_directory/MMSA/src/MMSA/__main__.py", line 3, in <module>
    from .run import MMSA_run
ImportError: attempted relative import with no known parent package

I'm not trying to run this script in a conda environment and I've also tried to put MMSA. in front of the first relative imports of run.py (lines 18 to 22), which gave me the following message :

SENA_run is not loaded due to missing dependencies. This is ok if you are not using M-SENA.

Thank you for your help, I'll be able to provide more informations if you need

FlameSky-S commented 2 years ago

Hi, thank you for your attention. You're using version 2.0 which we updated recently. We're sorry that the README file is still for v1.0, which might be very confusing. We'll update it as soon as possible.

In your case, if you're trying to run MMSA from source, you need to call MMSA_run from outside the package. The import should be from src.MMSA.run import MMSA_run. This would be a little bit messy since all dependencies are not automatically installed. However, if you're not interested in editing the code and just want to run some tests, it is recommended to install the MMSA package from PyPi using pip install MMSA. Then you can import with from MMSA import MMSA_run in your python file.

BastianBN commented 2 years ago

Hi, first of all, thank you for your help !

It seems I managed to run the script by changing from run import MMSA_run to from MMSA.run import MMSA_run in the src/MMSA/__main__.py file. I still kept my changes in run.py and added MMSA. in lines 18 to 22 as well.

I'm now wondering if it is possible to run the self_mm model with aligned data ? It doesn't seem that an argument to chose which data to use exists.

I will keep you updated if I run into more issues that would be linked to imports !

Columbine21 commented 2 years ago

Hi, @Banzai99 Thanks for your attention to our works.

In fact, all models provided here can run in both aligned and unaligned modes. For approaches designed on unaligned mode, no extra module is used to run on aligned mode. (aligned can be regarded as an extreme case of unaligned). For approaches designed on aligned mode, to run on unaligned settings, some alignment modules (models/subNets/AlignNets.py) should be used to do "model aligned" to process the unaligned original data into the aligned format.

To do that, in our framework, change the config files. "need_data_aligned" items in each model to change whether aligned data or unaligned ones. "need_model_aligned": true items in each model to add alignment module to use model designed on aligned settings for Unaligned Scenarios.

BastianBN commented 2 years ago

Hi @Columbine21 and thank you for your help

Ok, I've taken a more in-depth look to the config files and I managed to run the code and replicate the results ! I would have a very last question about the names of the results. Has0_ and Non0_ stands for the 2 ways of managing polarity ? Either by calculating "negative/non negative" or "negative/positive" ?

Thank you both for your time and much appreciated help !

Columbine21 commented 2 years ago

Hi, @Banzai99 you are right, in most previous MSA research, binary acc and F1 scores are calculated in negative/non-negative settings (referring to the Has0_ ways). In MulT and MISA, researchers find that negative/positive (referring to the Non_0 ways) settings can achieve better performances and report them.

For Fairly comparison for both work on Has0_ and Non0_ ways, current MSA researchers record all of them.

BastianBN commented 2 years ago

Hi @Columbine21,

Perfect then !

Thank you so much for your help and good luck in your future projects !

BastianBN commented 2 years ago

I just realized I forgot a question, sorry for reopening the issue but, is it possible to reproduce results for self-mm without training on all modalities ? Specially to reproduce this table from the associated paper : image

Columbine21 commented 2 years ago

Hi, @Banzai99 Notice that this is an ablation study for multi-task supervision not for multimodal features. The model architecture is maintained, where A/T/V modality supervise (tasks / losses) are ablated.

BDHU commented 1 year ago

This problem still exists and it would be nice to have some sort of fixes:)

FlameSky-S commented 1 year ago

This problem still exists and it would be nice to have some sort of fixes:)

Hi, do you mean the relative import issue? Have you tried methods from this link?