nikicc / twitter-emotion-recognition

Models for predicting emotions from English tweets.
GNU Affero General Public License v3.0
163 stars 68 forks source link

Unable to open file Error #25

Closed Ashwinneogi closed 3 years ago

Ashwinneogi commented 3 years ago

Hi,

I've been trying to implement your code. However, it gives me a "file not found" error. The path of the file in the error seemed to be incorrect. According to my understanding, I changed the path of the file in below code in emotion_predictor.py to the correct path

def _get_model(self):
        self._loaded_model_filename = '**mypath**/models/{}{}-{}.h5'.format(
            'unison-' if self.use_unison_model else '',
            self.classification,
            self.setting,

However, it still gives the same error with the earlier path name. error

Please see the screenshot. Any help would be much appreciated

nikicc commented 3 years ago

I've been trying to implement your code. However, it gives me a "file not found" error. The path of the file in the error seemed to be incorrect.

Yes. The code assumes you are running the scrip in the top-level directory. If you are, then the model/unison-ekman-mc.h5 should work as a relative path to the model. Please check the current working directory (e.g. with os.getcwd(); see more).

I changed the path of the file in below code in emotion_predictor.py to the correct path

In theory that should work. Not really sure why it doesn't. Did you double check that the newly constructed path is OK? Also, keep in mind you'll also need to edit the allowed-chars.pkl path, if you're going down this road.

Ashwinneogi commented 3 years ago

Hello, Thanks for the prompt reply.

The script is indeed running in the top-level directory. Infact I have set the path manually as well as shown below

import sys
sys.path.append('/content/twitter-emotion-recognition-master')

Yes, as what you told, it should work as a relative path but it isn't and I am not sure why.

The other option of constructing a new path also gave me the same error. However, what is surprising is that when I choose to construct/change the path on my own in the emotion_predictor.py . The changed path should display in the error message. For example, In the emotion_predictor.py I changed the path to:

self._loaded_model_filename = '/content/twitter-emotion-recognition-master/models/{}{}-{}.h5'

and I should expect this path to be displayed in the error message. Please see the screenshot below. error2

It looks like the name parameter is directed to somewhere else? I am really not sure.

Thanks for you time!

nikicc commented 3 years ago

@Ashwinneogi it seems like the place where you execute the code on the left, is not picking up the edits you are making in the file on the right. Can you try running the emotion_predictior.py directly in the command line?

Ashwinneogi commented 3 years ago

@nikicc I ran the code directly and it seems to not have any problems. error3

nikicc commented 3 years ago

@Ashwinneogi happy to hear this. Yes, I assumed it's something with the way the code is run. I'm closing this issue as it does not seem to be an actual code issue.