Facial-Expression-Recognition icon indicating copy to clipboard operation
Facial-Expression-Recognition copied to clipboard

NameError: name 'flags' is not defined

Open gauravrajan opened this issue 5 years ago • 9 comments

I am using a windows 10 system. I have also installed all dependencies. on running main.py , both the command prompt as well as the python shell display the following:

C:\Users\410379\Python37\Facial-Expression-Recognition-master>python main.py Traceback (most recent call last): File "main.py", line 6, in flags.DEFINE_string('MODE', 'demo', NameError: name 'flags' is not defined

gauravrajan avatar May 01 '19 13:05 gauravrajan

Has this problem been solved?

xionghc avatar May 09 '19 11:05 xionghc

no, I have been waiting for your help.

gauravrajan avatar May 09 '19 11:05 gauravrajan

Have you modified the code?

xionghc avatar May 09 '19 11:05 xionghc

Check if the 5th line of main.py is flags = tf.app.flags.

xionghc avatar May 09 '19 11:05 xionghc

i have not changed any code. Here is the copy paste of 5th line

flags = tf.app.flags

gauravrajan avatar May 09 '19 13:05 gauravrajan

from demo import demo from model import train_model, valid_model import tensorflow as tf

flags = tf.app.flags flags.DEFINE_string('MODE', 'demo', 'Set program to run in different mode, include train, valid and demo.') flags.DEFINE_string('C:\Users\410379\Python37\Facial-Expression-Recognition-master\ckpt', 'C:\Users\410379\Python37\Facial-Expression-Recognition-master') flags.DEFINE_string('train_data', './data/fer2013/fer2013.csv', 'Path to training data.') flags.DEFINE_string('valid_data', './valid_sets/', 'C:\Users\410379\Python37\Facial-Expression-Recognition-master') flags.DEFINE_boolean('show_box', False, 'If true, the results will show detection box') FLAGS = flags.FLAGS

def main(): assert FLAGS.MODE in ('train', 'valid', 'demo')

if FLAGS.MODE == 'demo': demo(FLAGS.checkpoint_dir, FLAGS.show_box) elif FLAGS.MODE == 'train': train_model(FLAGS.train_data) elif FLAGS.MODE == 'valid': valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)

if name == 'main': main()

gauravrajan avatar May 09 '19 13:05 gauravrajan

above is a copy paste of the entire main.py where I have just modified the paths wherever applicable as per my directory

gauravrajan avatar May 09 '19 13:05 gauravrajan

Try to run the below code. Please feedback the result to me.

import tensorflow as tf
flags = tf.app.flags
flags.DEFINE_string('mode', 'demo', 'help')
print('success')

xionghc avatar May 10 '19 02:05 xionghc

Have you published relevant articles on this algorithm?Can you reply the title or link of the article if there is any?Thank you very much

lemonmimi avatar Jun 11 '19 09:06 lemonmimi