tf-insightface icon indicating copy to clipboard operation
tf-insightface copied to clipboard

Import errors

Open yuskey opened this issue 5 years ago • 6 comments

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?

yuskey avatar Apr 18 '19 17:04 yuskey

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

Anurag14 avatar May 08 '19 07:05 Anurag14

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

Anurag14 avatar May 08 '19 09:05 Anurag14

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

xingyi-li avatar Aug 26 '19 03:08 xingyi-li

@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 avatar Sep 16 '19 13:09 dasmehdix

@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:

  1. 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)
  1. 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
'''
  1. 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
  1. 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
  1. In apps/__init__.py:
import sys
sys.path.insert(0, '.')

xingyi-li avatar Sep 16 '19 14:09 xingyi-li

@singngai Thank you SO MUCH:) <3 <3 <3 <3 Worked :)

dasmehdix avatar Sep 16 '19 14:09 dasmehdix