tf-insightface
tf-insightface copied to clipboard
Import errors
Hey guys, I keep getting an issue importing the submodules like models, etc. I'm not sure if this is a python 3 issue or what? Essentially it does not find the models module when I am running example.py, any ideas?
I am also facing same issue Import error no module named models
$ tf-insightface> python apps/demo.py
Is the command that i gave to run demo
Insert following lines to the files in apps folder at the top
import sys
sys.path.insert(0, '.')
and in models/face_tracker_server.py
from models import base_server
Then try and run both python apps/demo.py
and python apps/example.py
Thanks for @Anurag14 's solution, but in order to run correctly:
in models/face_describer_server.py, instead of import base_server
, use from models import base_server
, no need to add from models import base_server
in models/face_tracker_server.py
@singngai @Anurag14 @yuskey @KleinYuan
I added that code to apps/demo.py and apps/example.py
import sys sys.path.insert(0, '.')
Still I get error about "no module named models".
please help me, I also changed models/face_describer_server.py.
@dasmehdix Hi, I'm delighted to help you, but I'm not sure if I still remember how to correctly solve this issue because it has been a long time since I tackled this problem. Anyway, I can offer you the following suggestions, please feel free to contact me if you still aren't capable of solving this issue :-), check them out:
- In models/face_describer_server.py:
# import base_server
from models import base_server
class FDServer(base_server.BaseServer):
def __init__(self, *args, **kwargs):
super(FDServer, self).__init__(*args, **kwargs)
- In models/face_tracker_server.py:
import cv2
import face_recognition
'''
This server:
Input: Camera frame
Output: Relative locations for each face, with [(tr_x, tr_y, bl_x, bl_y)]
x1,y1 ------
| |
| |
| |
--------x2,y2
'''
- In apps/demo.py:
import sys
sys.path.insert(0, '.')
import cv2
import numpy as np
from models import face_track_server, face_describer_server, face_db, camera_server
from configs import configs
- In apps/example.py:
import sys
sys.path.insert(0, '.')
import cv2
import numpy as np
from models import base_server
from configs import configs
- In apps/__init__.py:
import sys
sys.path.insert(0, '.')
@singngai Thank you SO MUCH:) <3 <3 <3 <3 Worked :)