yinguobing / facial-landmark-detection-hrnet

A TensorFlow implementation of HRNet for facial landmark detection.
GNU General Public License v3.0
158 stars 40 forks source link

运行报错 #7

Open z2kp48 opened 3 years ago

z2kp48 commented 3 years ago

您好,作为一个小白,看到您的博文后想运行一下代码,但是发生了错误。下边是报错情况和我觉得出问题的地方。 File "C:/Users/RPPG/Desktop/pyCode/facial-landmark-detection-hrnet-master/predict.py", line 37, in model = tf.keras.models.load_model("assets/face_model/saved_model.pb") File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\keras\saving\save.py", line 211, in load_model loader_impl.parse_saved_model(filepath) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\loader_impl.py", line 111, in parse_saved_model raise IOError("SavedModel file does not exist at: %s/{%s|%s}" % OSError: SavedModel file does not exist at: assets/face_model/saved_model.pb/{saved_model.pbtxt|saved_model.pb}

Restore the model.

model = tf.keras.models.load_model("./exported/hrnetv2")

因为在百度云盘下载后,我将其中的内容放在了asset中,也不知道对不对。 谢谢!

yinguobing commented 3 years ago

百度云盘的两个链接一个是checkpoint,一个是SavedModel。你用的是哪一个呀?

z2kp48 commented 3 years ago

SavedModel那一个。

yinguobing commented 3 years ago

可以列出pb文件的完整路径吗?有可能是路径的问题。

z2kp48 commented 3 years ago

Construct a face detector.

detector_face = Detector('assets/face_model/saved_model.pb')

# Restore the model.
model = tf.keras.models.load_model("./exported/hrnetv2")

谢谢您的回复,但是我不确定是将下载的模型放到哪句代码中。

z2kp48 commented 3 years ago

我以刚才的代码运行后,出现这种情况。 Traceback (most recent call last): File "C:/Users/RPPG/Desktop/pyCode/facial-landmark-detection-hrnet-master/predict.py", line 34, in detector_face = Detector('assets/face_model/saved_model.pb') File "C:\Users\RPPG\Desktop\pyCode\facial-landmark-detection-hrnet-master\face_detector\detector.py", line 33, in init imported = tf.saved_model.load(saved_model) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\load.py", line 859, in load return load_internal(export_dir, tags, options)["root"] File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\load.py", line 871, in load_internal loader_impl.parse_saved_model_with_debug_info(export_dir)) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\loader_impl.py", line 56, in parse_saved_model_with_debug_info saved_model = _parse_saved_model(export_dir) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\loader_impl.py", line 111, in parse_saved_model raise IOError("SavedModel file does not exist at: %s/{%s|%s}" % OSError: SavedModel file does not exist at: assets/face_model/saved_model.pb/{saved_model.pbtxt|saved_model.pb}

Process finished with exit code 1

而且从github上下载代码后,我将asset文件中的原本的模型和变量改成的百度云盘中的模型和变量,不知道这样的操作是否正确。

yinguobing commented 3 years ago

GitHub上下载的代码先不做任何改动。留意这行代码:

model = tf.keras.models.load_model("./exported/hrnetv2")

其中暗含了SavedModel应该存放的位置。你可以把这里的相对路径改为你计算机上的绝对路径。

我留意到你使用的应该是Windows操作系统,注意它的路径表述与Linux不同。所以你可能还需要把检测器加载的文件路径也检查一下:

detector_face = Detector('assets/face_model/saved_model.pb')
z2kp48 commented 3 years ago

在使用绝对路径后,还是会报错,跟之前的错误是一样的。 File "C:/Users/RPPG/Desktop/pyCode/landmark/predict.py", line 34, in detector_face = Detector('assets/face_model/saved_model') File "C:\Users\RPPG\Desktop\pyCode\landmark\face_detector\detector.py", line 33, in init imported = tf.saved_model.load(saved_model) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\load.py", line 859, in load return load_internal(export_dir, tags, options)["root"] File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\load.py", line 871, in load_internal loader_impl.parse_saved_model_with_debug_info(export_dir)) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\loader_impl.py", line 56, in parse_saved_model_with_debug_info saved_model = _parse_saved_model(export_dir) File "C:\Users\RPPG\Anaconda3\envs\ippg\lib\site-packages\tensorflow\python\saved_model\loader_impl.py", line 111, in parse_saved_model raise IOError("SavedModel file does not exist at: %s/{%s|%s}" % OSError: SavedModel file does not exist at: assets/face_model/saved_model/{saved_model.pbtxt|saved_model.pb}

Process finished with exit code 1

在网上查询错误原因后,将tensorflow改成了gpu版本,也是不对的。

我所有的错做过程如下: 在github上下载源代码。然后在github上下载models文件夹和face-detector文件夹所需要的代码。然后在百度云盘下载提供的已经训练好的model。 detector_face = Detector('assets/face_model/saved_model.pb') 这里使用的是原文件所提供的model路径 model = tf.keras.models.load_model("./exported/hrnetv2") 这里使用了从百度云盘所使用的model路径

真的很感谢您能在百忙之中回复我的信息。

z2kp48 commented 3 years ago

非常感谢,我重新下载了一遍代码之后问题解决了,谢谢

yinguobing commented 3 years ago

客气了。有时间的话可以学习一下Git,这样遇到的问题会少很多。

anil-bit commented 2 years ago

hi ,really sorry to disturb you but i have already downloaded from baidu cloud disk but cannot find "model.pbtxt|saved_model.pb"

anil-bit commented 2 years ago

Screenshot_20220517_102730

yinguobing commented 2 years ago

@anil-bit Please download the checkpoint file from GoogleDrive.

anil-bit commented 2 years ago

谢谢你

yinguobing commented 2 years ago

谢谢你

😃

anil-bit commented 2 years ago

image

anil-bit commented 2 years ago

使用哪一个?