dpressel / rude-carnie

Age detection in Tensorflow
937 stars 341 forks source link

Age *or* gender work for me - how can I do both? #63

Closed alvervalleysoftware closed 6 years ago

alvervalleysoftware commented 6 years ago

Hi,

Firstly, thanks for this - it's a really useful repo, and I can run either age or gender classifications successfully.

I need to run both on a given image - but I'm running into problems with multiple instances of the graph loaded. Whatever I do, I get problems around the 'model_fn()' line - when I call that again for a second time with a different number of labels, I get errors like "ValueError: Variable InceptionV3/Conv2d_1a_3x3/weights already exists, disallowed".

I realise that this is a more general question about how to have two Estimators loaded at once, but I need to do it in this specific case. Can anyone help?

Thanks in advance.

dpressel commented 6 years ago

You can create multiple sessions with graphs. e.g.

        g = tf.Graph()
        with g.as_default():
            sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
            ...

This is how, for instance, we load the YOLO TF model for object detection prior to running the model in guess.py, so maybe see that code as a reference.

alvervalleysoftware commented 6 years ago

Thanks - I'll give that a try.