bubbliiiing / arcface-keras

这是一个arcface-keras的源码,可以用于训练自己的模型。
MIT License
8 stars 2 forks source link

conv2d重复使用,是哪里有问题吗 #1

Open 123yuhan opened 1 year ago

123yuhan commented 1 year ago

Traceback (most recent call last): File "D:\Pycharm\Project1\arcface-keras\predict.py", line 6, in model = Arcface() File "D:\Pycharm\Project1\arcface-keras\arcface.py", line 51, in init self.generate() File "D:\Pycharm\Project1\arcface-keras\arcface.py", line 61, in generate self.model = arcface(self.input_shape, backbone=self.backbone, mode="predict") File "D:\Pycharm\Project1\arcface-keras\nets\arcface.py", line 64, in arcface model = Model(inputs, x) File "D:\Python3.8\python3.8\lib\site-packages\tensorflow\python\keras\engine\training.py", line 242, in new return functional.Functional(*args, kwargs) File "D:\Python3.8\python3.8\lib\site-packages\tensorflow\python\training\tracking\base.py", line 457, in _method_wrapper result = method(self, *args, *kwargs) File "D:\Python3.8\python3.8\lib\site-packages\tensorflow\python\keras\engine\functional.py", line 115, in init self._init_graph_network(inputs, outputs) File "D:\Python3.8\python3.8\lib\site-packages\tensorflow\python\training\tracking\base.py", line 457, in _method_wrapper result = method(self, args, kwargs) File "D:\Python3.8\python3.8\lib\site-packages\tensorflow\python\keras\engine\functional.py", line 190, in _init_graph_network nodes, nodes_bydepth, layers, = _map_graph_network( File "D:\Python3.8\python3.8\lib\site-packages\tensorflow\python\keras\engine\functional.py", line 941, in _map_graph_network raise ValueError('The name "' + name + '" is used ' + ValueError: The name "conv2d" is used 2 times in the model. All layer names should be unique.

进程已结束,退出代码1

bubbliiiing commented 1 year ago

你有修改什么吗 0 0

123yuhan commented 1 year ago

可能因为版本不同,运行不了,用到的包修改的挺多的,但是代码部分没修改

bubbliiiing commented 1 year ago

什么版本咧,告诉我一下

123yuhan commented 1 year ago

什么版本咧,告诉我一下

使用的是python3.8,keras2.3.0,tensorflow-gpu2.3.0。下载打开项目后,将从keras导入的包替换成tensorflow.keras,其他代码没有修改,然后运行predict时报错。

bubbliiiing commented 1 year ago

额……你的版本完全不对欸……不太合适

bubbliiiing commented 1 year ago

你直接用tf2版本的啊

123yuhan commented 1 year ago

你直接用tf2版本的啊

比如现在train.py中导入的包改成了这样 ` import datetime import os import numpy as np import tensorflow as tf1 from tensorflow.keras.callbacks import LearningRateScheduler, ModelCheckpoint, TensorBoard from tensorflow.keras.layers import Conv2D, Dense, DepthwiseConv2D, PReLU from tensorflow.keras.optimizers import SGD, Adam from tensorflow.keras.regularizers import l2 from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model

from nets.arcface import arcface from nets.arcface_training import ArcFaceLoss, get_lr_scheduler from utils.callbacks import (ExponentDecayScheduler, LFW_callback, LossHistory, ParallelModelCheckpoint) from utils.dataloader import FacenetDataset, LFWDataset from utils.utils import get_acc, get_num_classes, show_config tf = tf1.compat.v1 tf.disable_eager_execution() tf.logging.set_verbosity(tf.logging.ERROR) `

123yuhan commented 1 year ago

你直接用tf2版本的啊

啊这,您的意思是不用keras,直接用tf? 还是使用tf2,因为代码中有些使用tf的时候,会出现函数调用找不到,需要将tf改为tf1版本。

bubbliiiing commented 1 year ago

不是啊,有个tf2的库啊

123yuhan commented 1 year ago

不是啊,有个tf2的库啊

不好意思啊,我没太清楚您的意思。我是下载这个项目打开后运行会报tf2版本的错误,所以把tf2改成的tf1,也把keras改成了tensorflow.keras。因为之前用过您的另一个项目facenet-keras,也是这样调试的,调试完成后能够正确运行。我现在是把最上面提到的出错的地方“name=conv2d"直接删了。。不知道正确的修改方式是什么。还有一个点想请教您,就是facenet-keras和arcface-keras最后使用项目里面自带的.h5模型进行预测,最后的准确率都只有80左右,不知道是不是因为您提到的环境版本问题的影响。