Traceback (most recent call last):
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/app/face_similarity.py", line 36, in calculate_deepface_similarity
result = DeepFace.verify(ekyc_image_rgb, attendance_image_rgb, model_name='Facenet512')
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/DeepFace.py", line 169, in verify
img1_embedding_obj = represent(
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/DeepFace.py", line 639, in represent
model = build_model(model_name)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/DeepFace.py", line 80, in build_model
model = model()
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/basemodels/Facenet512.py", line 11, in loadModel
model = Facenet.InceptionResNetV2(dimension=512)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/basemodels/Facenet.py", line 49, in InceptionResNetV2
inputs = Input(shape=(160, 160, 3))
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/keras/engine/input_layer.py", line 270, in Input
input_layer = InputLayer(**input_layer_config)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/keras/engine/input_layer.py", line 122, in _init_
input_tensor = backend.placeholder(
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/keras/backend.py", line 1054, in placeholder
x = array_ops.placeholder(dtype, shape=shape, name=name)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/ops/array_ops.py", line 2718, in placeholder
return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/ops/gen_array_ops.py", line 6031, in placeholder
_, _, _op, _outputs = _op_def_library._apply_op_helper(
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/op_def_library.py", line 740, in _apply_op_helper
op = g._create_op_internal(op_type_name, inputs, dtypes=None,
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/func_graph.py", line 593, in _create_op_internal
return super(FuncGraph, self)._create_op_internal( # pylint: disable=protected-access
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/ops.py", line 3307, in _create_op_internal
node_def = _NodeDef(op_type, name, attrs)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/ops.py", line 1569, in _NodeDef
node_def.attr[k].CopyFrom(v)
File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/google/protobuf/internal/containers.py", line 70, in _getitem_
return self._values[key]
TypeError: list indices must be integers or slices, not str
Версия Android Studio: Android Studio Giraffe | 2022.3.1 Патч 2
Версия Gradle: 8.1.2
Версия DeepFace: 0.0.79
Версия Chaquopy: 14.0.2
Зависимости, которые я установил: deepface, numpy и opencv-python.
Кроме того, есть ли возможность запуска команд для проверки версий Python, работающих так как продублировать это в виртуальной среде локальной системы. Код face_similarity.py отлично работает в моей локальной системе, а также в виртуальной среде Windows.
Если у кого-нибудь есть идеи, что я могу сделать, чтобы это исправить, я был бы рад, если бы они помог мне. Спасибо.
Я пробовал устанавливать различные комбинации библиотек в файл build.gradle, включая deepface, open-cv-python, и часто получал сообщение об ошибке, что версия opencv-python тоже не найдена. и я не могу дублировать локальную среду Python в Chaquopy Java Kotlin Android Studio
Я пытаюсь запустить следующий фрагмент кода для deepface для сравнения двух изображений, содержащих лицо. Код Python: face_similarity.py [code]import base64 from io import BytesIO from PIL import Image import numpy as np import cv2 from deepface import DeepFace import traceback import tensorflow as tf import vitis_quantizer
def convert_to_tflite(model, tflite_filename): # Convert the model to TFLite format converter = tf.lite.TFLiteConverter.from_saved_model(model) tflite_model = converter.convert()
# Save the TFLite model to a file with open(tflite_filename, 'wb') as f: f.write(tflite_model)
def calculate_deepface_similarity(ekyc_base64, attendance_base64): if not ekyc_base64 or not attendance_base64: return "image is missing"
if ekyc_image is None or attendance_image is None: return "invalid image data"
# Ensure both images are in portrait orientation ekyc_image = _convert_to_portrait(ekyc_image) attendance_image = _convert_to_portrait(attendance_image)
def encode_image_to_base64(file_path): try: with open(file_path, "rb") as image_file: # Read the image file in binary mode image_binary = image_file.read()
# Encode the binary data to base64 encoded_string = base64.b64encode(image_binary).decode("utf-8")
if __name__ == "__main__": # Example usage ekyc_base64 = encode_image_to_base64("Screenshot 2023-11-26 220725.png") attendance_base64 = encode_image_to_base64("Screenshot 2023-11-26 220806.png")
similarity_percentage = calculate_deepface_similarity(ekyc_base64, attendance_base64) print("Similarity Percentage:", similarity_percentage) [/code] Однако я столкнулся со следующей ошибкой: [code]Traceback (most recent call last): File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/app/face_similarity.py", line 36, in calculate_deepface_similarity result = DeepFace.verify(ekyc_image_rgb, attendance_image_rgb, model_name='Facenet512') File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/DeepFace.py", line 169, in verify img1_embedding_obj = represent( File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/DeepFace.py", line 639, in represent model = build_model(model_name) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/DeepFace.py", line 80, in build_model model = model() File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/basemodels/Facenet512.py", line 11, in loadModel model = Facenet.InceptionResNetV2(dimension=512) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/deepface/basemodels/Facenet.py", line 49, in InceptionResNetV2 inputs = Input(shape=(160, 160, 3)) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/keras/engine/input_layer.py", line 270, in Input input_layer = InputLayer(**input_layer_config) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/keras/engine/input_layer.py", line 122, in _init_ input_tensor = backend.placeholder( File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/keras/backend.py", line 1054, in placeholder x = array_ops.placeholder(dtype, shape=shape, name=name) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/ops/array_ops.py", line 2718, in placeholder return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/ops/gen_array_ops.py", line 6031, in placeholder _, _, _op, _outputs = _op_def_library._apply_op_helper( File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/op_def_library.py", line 740, in _apply_op_helper op = g._create_op_internal(op_type_name, inputs, dtypes=None, File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/func_graph.py", line 593, in _create_op_internal return super(FuncGraph, self)._create_op_internal( # pylint: disable=protected-access File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/ops.py", line 3307, in _create_op_internal node_def = _NodeDef(op_type, name, attrs) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/tensorflow_core/python/framework/ops.py", line 1569, in _NodeDef node_def.attr[k].CopyFrom(v) File "/data/data/rural.ekyc/files/chaquopy/AssetFinder/requirements/google/protobuf/internal/containers.py", line 70, in _getitem_ return self._values[key] TypeError: list indices must be integers or slices, not str [/code] Мой build.gradle: [code]import java.text.SimpleDateFormat
plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android'
id 'kotlin-android' id 'kotlin-parcelize' id 'kotlin-kapt' id 'dagger.hilt.android.plugin' id 'androidx.navigation.safeargs.kotlin' id 'com.google.gms.google-services' id 'com.google.firebase.crashlytics'
} [/code] Вывод pipFree>requirements.txt для моей виртуальной среды Windows, работающей на Python 3.10.9, выглядит следующим образом [code]absl-py==2.0.0 astunparse==1.6.3 beautifulsoup4==4.12.2 blinker==1.7.0 cachetools==5.3.2 certifi==2023.7.22 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 deepface==0.0.79 filelock==3.13.1 fire==0.5.0 Flask==3.0.0 flatbuffers==23.5.26 gast==0.5.4 gdown==4.7.1 google-auth==2.23.4 google-auth-oauthlib==1.0.0 google-pasta==0.2.0 grpcio==1.59.2 gunicorn==21.2.0 h5py==3.10.0 idna==3.4 itsdangerous==2.1.2 Jinja2==3.1.2 keras==2.14.0 libclang==16.0.6 Markdown==3.5.1 MarkupSafe==2.1.3 ml-dtypes==0.2.0 mtcnn==0.1.1 numpy==1.26.2 oauthlib==3.2.2 opencv-python==4.8.1.78 opt-einsum==3.3.0 packaging==23.2 pandas==2.1.3 Pillow==10.1.0 protobuf==4.25.0 pyasn1==0.5.0 pyasn1-modules==0.3.0 PySocks==1.7.1 python-dateutil==2.8.2 pytz==2023.3.post1 requests==2.31.0 requests-oauthlib==1.3.1 retina-face==0.0.13 rsa==4.9 six==1.16.0 soupsieve==2.5 tensorboard==2.14.1 tensorboard-data-server==0.7.2 tensorflow==2.14.0 tensorflow-estimator==2.14.0 tensorflow-intel==2.14.0 tensorflow-io-gcs-filesystem==0.31.0 termcolor==2.3.0 tqdm==4.66.1 typing_extensions==4.8.0 tzdata==2023.3 urllib3==2.1.0 Werkzeug==3.0.1 wrapt==1.14.1 [/code] Версия Android Studio: Android Studio Giraffe | 2022.3.1 Патч 2 Версия Gradle: 8.1.2 Версия DeepFace: 0.0.79 Версия Chaquopy: 14.0.2 Зависимости, которые я установил: deepface, numpy и opencv-python. Кроме того, есть ли возможность запуска команд для проверки версий Python, работающих так как продублировать это в виртуальной среде локальной системы. Код face_similarity.py отлично работает в моей локальной системе, а также в виртуальной среде Windows. Если у кого-нибудь есть идеи, что я могу сделать, чтобы это исправить, я был бы рад, если бы они помог мне. Спасибо. Я пробовал устанавливать различные комбинации библиотек в файл build.gradle, включая deepface, open-cv-python, и часто получал сообщение об ошибке, что версия opencv-python тоже не найдена. и я не могу дублировать локальную среду Python в Chaquopy Java Kotlin Android Studio