tensorflow / tensorflow/models

deeplab tensorflow model_test.py works fine, but import error in main.py

Open
#10,077 0 comments 0 reactions 2 assignees View on GitHub

Nobody has claimed this yet.

models:research type:bug
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

I would like to use deeplab on macOS Python 3.7. I have to install tensorflow v1.15 (due to deeplab compatibility problem).
I install tensorflow models and extract it to:
./PROJECT_NAME/venv/lib/python3.7/site-packages/tensorflow.

Now, I have read in tensorflow installation guide, that I should execute in terminal:

>>> $ pwd
>>> ./PROJECT_NAME/venv/lib/python3.7/site-packages/tensorflow/models/research
>>> $ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim.

After that I test it from the same path: $ python deeplab/model_test.py and it works fine:

Ran 5 tests in 35.463s
OK (skipped=1)

PROBLEM: So, I would like to test it in my project in path PROJECT_NAME/main.py simple way:

from matplotlib import pyplot as plt
import cv2

from model import Deeplabv3

deeplab_model = Deeplabv3()

and $ python main.py gives me:

    from model import Deeplabv3
ModuleNotFoundError: No module named 'model'

I have already tried to move deeplab model folder to ./PROJECT_NAME/ and in another way move main.py to deeplab folder:

from deeplab import model # this way import
deeplab_model = Deeplabv3()
NameError: name 'Deeplabv3' is not defined

I researched model_test.py code and they import in another way, but in the example (in other github repo the same import I couldn't find what I'm doing wrong. I'm not very familiar in python. Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.