#๐Ÿ”’ import errors

26 messages ยท Page 1 of 1 (latest)

unborn field
#

from tensorflow.python.keras.applications import MobileNetV2
from tensorflow.python.keras.applications.mobilenet_v2 import preprocess_input

I keep getting errors when i try to import this. How do i import preprocess_input and MobileNetV2

wanton havenBOT
#

@unborn field

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hybrid hatch
unborn field
#

I tried that, and it didn't work

#

But the .python submodule worked for other keras imports on vscode

#

I am only having issues with MobileNetV2 and preprocess_input

hybrid hatch
#

i am scared to ask how you set up your environment, but keras should be installed as its own module so you could also try from keras import applications

unborn field
#

okay, I did that and I gave no errors

#

But can I use MobileNetV2 and preprocess_input with just that?

hybrid hatch
#

yep

#

tf just re-exports keras

unborn field
#

sorry i didnt get that

#

i should re export it

#

?

hybrid hatch
#

no, just saying internally that tensorflow exposes keras as a submodule of itself
this pic is from tensorflow's init.py

#

it doesn't mess with keras at all, so tf.keras and keras are exactly the same

unborn field
#

ohh okay

hybrid hatch
#

it's just trying to figure out if it needs to expose keras v2 or v3

unborn field
#

so if i import applications with from keras import applications...then i can call MobileNetV2 and preprocess_input

hybrid hatch
#

i haven't touched this part of the docs before, it's very confusing

unborn field
#

oh okay. I'll check out the docs

#

thanks

wanton havenBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.