如何摆脱错误 "Fatal signal 11 (SIGSEGV), code 1, fault addr 0x70"
How to get rid of the error "Fatal signal 11 (SIGSEGV), code 1, fault addr 0x70"
我正在做我的 android 项目。基本上,用户输入一段文本,然后模型预测它是否具有冒犯性。这是通过在 python 上训练深度学习模型 LSTM 完成的。然后我将它部署到云端 (Firebase)。并将其下载到我的 android phone 中,如果已下载,则从远程模型创建一个解释器。现在,当我尝试 运行 应用程序时,模型是从云端下载的,但它给出了一个错误。错误消息的 PFA 屏幕截图。
让我知道我做错了什么以及为什么会出现这样的错误?
这是我运行应用程序时得到的日志,
$ adb shell am start -n "com.example.fyp_screens/com.example.fyp_screens.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 32675 on device 'infinix-infinix_hot_4_pro-02576117BM001236'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/skia: SkJpegCodec::onGetPixels +
D/skia: SkJpegCodec::onGetPixels -
I/art: Enter while loop.
I/art: Enter while loop.
I/art: Enter while loop.
I/art: Enter while loop.
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@c10efc6[]
D/WindowClient: Add to mViews: DecorView@c10efc6[MainActivity], this = android.view.WindowManagerGlobal@94c3ad1
D/OpenGLRenderer: Dumper init 2 threads <0x74c0298880>
<com.example.fyp_screens> is running.
D/OpenGLRenderer: CanvasContext() 0x74c4eda000
D/GraphicBuffer: register, handle(0x74c0305540) (w:896 h:1024 s:896 f:0x1 u:0x000100)
D/ViewRootImpl[MainActivity]: hardware acceleration is enabled, this = ViewRoot{e06e936 com.example.fyp_screens/com.example.fyp_screens.MainActivity,ident = 0}
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{e06e936 com.example.fyp_screens/com.example.fyp_screens.MainActivity,ident = 0}, this = DecorView@c10efc6[MainActivity]
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = ViewRoot{e06e936 com.example.fyp_screens/com.example.fyp_screens.MainActivity,ident = 0}, this = DecorView@c10efc6[MainActivity]
D/statusbar color: isDarkStatusBar======false
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@a5f9058[]
D/WindowClient: Add to mViews: DecorView@a5f9058[HomeScreen], this = android.view.WindowManagerGlobal@94c3ad1
D/OpenGLRenderer: CanvasContext() 0x74c4edd800
D/ViewRootImpl[HomeScreen]: hardware acceleration is enabled, this = ViewRoot{592f1d7 com.example.fyp_screens/com.example.fyp_screens.HomeScreen,ident = 1}
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{592f1d7 com.example.fyp_screens/com.example.fyp_screens.HomeScreen,ident = 1}, this = DecorView@a5f9058[HomeScreen]
D/Surface: Surface::allocateBuffers(this=0x74cb854e00)
D/OpenGLRenderer: CanvasContext() 0x74c4edd800 initialize window=0x74cb854e00, title=com.example.fyp_screens/com.example.fyp_screens.HomeScreen
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
D/OpenGLRenderer: Created EGL context (0x74c4eb1280)
D/OpenGLRenderer: ProgramCache.init: enable enhancement 1
I/OpenGLRenderer: Get disable program binary service property (0)
Initializing program atlas...
I/ProgramBinary/Service: ProgramBinaryService client side disable debugging.
ProgramBinaryService client side disable binary content debugging.
D/ProgramBinary/Service: BpProgramBinaryService.getReady
D/ProgramBinary/Service: BpProgramBinaryService.getProgramBinaryData
I/OpenGLRenderer: Program binary detail: Binary length is 182828, program map length is 124.
I/OpenGLRenderer: Succeeded to mmap program binaries. File descriptor is 66, and path is /dev/ashmem.
No need to use file discriptor anymore, close fd(66).
D/OpenGLRenderer: Initializing program cache from 0x0, size = -1
D/MALI: eglCreateImageKHR:513: [Crop] 0 0 896 1024 img[896 1024]
D/Surface: Surface::connect(this=0x74cb854e00,api=1)
W/libEGL: [ANDROID_RECORDABLE] format: 1
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
D/OpenGLRenderer: CacheTexture 5 upload: x, y, width height = 0, 0, 109, 388
ProgramCache.generateProgram: 0
D/GraphicBuffer: register, handle(0x74afeb0680) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/OpenGLRenderer: ProgramCache.generateProgram: 1
D/OpenGLRenderer: ProgramCache.generateProgram: 34359738368
D/OpenGLRenderer: ProgramCache.generateProgram: 5242944
D/OpenGLRenderer: ProgramCache.generateProgram: 34359738371
D/OpenGLRenderer: ProgramCache.generateProgram: 240518168576
D/OpenGLRenderer: ProgramCache.generateProgram: 68719476736
D/GraphicBuffer: register, handle(0x74affbbd40) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
V/InputMethodManager: onWindowFocus: androidx.appcompat.widget.AppCompatEditText{e3bbf6 VFED..CL. .F....ID 60,364-660,455 #7f07003d app:id/editText} softInputMode=288 first=true flags=#81810100
I/Choreographer: Skipped 58 frames! The application may be doing too much work on its main thread.
D/GraphicBuffer: register, handle(0x74affbc940) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/ContentValues: Created a Custom Image Classifier.
D/ContentValues: Configured input & output data for the custom image classifier.
D/statusbar color: isDarkStatusBar======false
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@d37e0bb[]
D/WindowClient: Add to mViews: DecorView@d37e0bb[result1], this = android.view.WindowManagerGlobal@94c3ad1
D/OpenGLRenderer: CanvasContext() 0x74c4ee1000
D/ViewRootImpl[result1]: hardware acceleration is enabled, this = ViewRoot{251037f com.example.fyp_screens/com.example.fyp_screens.result1,ident = 2}
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{251037f com.example.fyp_screens/com.example.fyp_screens.result1,ident = 2}, this = DecorView@d37e0bb[result1]
D/OpenGLRenderer: CanvasContext() 0x74c4ee1000 initialize window=0x74cb855c00, title=com.example.fyp_screens/com.example.fyp_screens.result1
D/Surface: Surface::allocateBuffers(this=0x74cb855c00)
D/Surface: Surface::connect(this=0x74cb855c00,api=1)
W/libEGL: [ANDROID_RECORDABLE] format: 1
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
D/OpenGLRenderer: CacheTexture 5 upload: x, y, width height = 0, 0, 176, 452
D/GraphicBuffer: register, handle(0x74affdc440) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/OpenGLRenderer: ProgramCache.generateProgram: 8899172237312
D/OpenGLRenderer: ProgramCache.generateProgram: 8830452760576
D/OpenGLRenderer: ProgramCache.generateProgram: 8796093022211
D/OpenGLRenderer: ProgramCache.generateProgram: 8830452760579
I/art: Enter while loop.
I/art: Do partial code cache collection, code=15KB, data=25KB
I/art: After code cache collection, code=15KB, data=25KB
Increasing code cache capacity to 128KB
D/GraphicBuffer: register, handle(0x74c4e16980) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
V/InputMethodManager: onWindowFocus: null softInputMode=288 first=true flags=#81810100
D/GraphicBuffer: register, handle(0x74af4a7cc0) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
D/Surface: Surface::disconnect(this=0x74cb854e00,api=1)
D/GraphicBuffer: unregister, handle(0x74affbbd40) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
unregister, handle(0x74affbc940) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/GraphicBuffer: unregister, handle(0x74afeb0680) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/Surface: Surface::disconnect(this=0x74cb854e00,api=1)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = ViewRoot{592f1d7 com.example.fyp_screens/com.example.fyp_screens.HomeScreen,ident = 1}, this = DecorView@a5f9058[HomeScreen]
D/libc-netbsd: getaddrinfo: mlkit.googleapis.com get result from proxy gai_error = 0
I/System.out: [socket][0] connection mlkit.googleapis.com/172.217.19.170:443;LocalPort=-1(2000)
D/: [Posix_connect Debug]Process com.example.fyp_screens :443
I/System.out: [socket][/192.168.1.5:55721] connected
D/NativeCrypto: ssl=0x74c4e52480 NativeCrypto_SSL_do_handshake fd=0x74b1903a28 shc=0x74b1903a2c timeout_millis=0 client_mode=1 npn=0x0
D/NativeCrypto: ssl=0x74c4e52480 info_callback calling handshakeCompleted
D/NativeCrypto: ssl=0x74c4e52480 cert_verify_callback => 1
D/NativeCrypto: ssl=0x74c4e52480 NativeCrypto_SSL_get_certificate => NULL
I/System.out: [OkHttp] sendRequest>>
I/System.out: [OkHttp] sendRequest<<
D/NativeCrypto: ssl=0x74c4e52480 info_callback calling handshakeCompleted
I/ModelDownloadManager: Didn't schedule download for the updated model
E/ContentValues: succed to build FirebaseModelInterpreter.
I/art: Enter while loop.
I/tflite: Initialized TensorFlow Lite runtime.
***A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x70 in tid 349 (FirebaseMLHandl)***
这是 lstm-classifier 的代码,
public lstmClassifier(final Context context) throws FirebaseMLException {
final FirebaseCustomRemoteModel remoteModel =
new FirebaseCustomRemoteModel.Builder("offense-detector").build();
final FirebaseModelManager firebaseModelManager = FirebaseModelManager.getInstance();
firebaseModelManager
.isModelDownloaded(remoteModel)
.continueWithTask(
new Continuation<Boolean, Task<Void>>() {
@Override
public Task<Void> then(@NonNull Task<Boolean> task) throws Exception {
// Create update condition if model is already downloaded,
// otherwise create download
// condition.
FirebaseModelDownloadConditions conditions =
task.getResult()
? new FirebaseModelDownloadConditions.Builder()
.requireWifi()
.build() // Update condition that requires wifi.
: new FirebaseModelDownloadConditions.Builder()
.build(); // Download condition.
return firebaseModelManager.download(remoteModel, conditions);
}
})
.addOnSuccessListener(
new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void ignored) {
FirebaseModelInterpreterOptions interpreterOptions =
new FirebaseModelInterpreterOptions.Builder(
new FirebaseCustomRemoteModel.Builder("offense-detector").build())
.build();
try {
interpreter =
FirebaseModelInterpreter.getInstance(interpreterOptions);
Log.e(TAG, "succed to build FirebaseModelInterpreter. ");
} catch (FirebaseMLException e) {
Log.e(TAG, "Failed to build FirebaseModelInterpreter. ", e);
}
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception ignored) {
Toast.makeText(
context,
"Model download failed for image classifier, please check" +
" your connection.",
Toast.LENGTH_LONG)
.show();
}
});
Log.d(TAG, "Created a Custom Image Classifier.");
int[] inputDims = {1, 200};
int[] outputDims = {1,1};
dataOptions =
new FirebaseModelInputOutputOptions.Builder()
.setInputFormat(0, FirebaseModelDataType.INT32, inputDims)
.setOutputFormat(0, FirebaseModelDataType.FLOAT32, outputDims)
.build();
Log.d(TAG, "Configured input & output data for the custom image classifier.");
}//constructor
这似乎是tensorflow-lite 库内部问题。您的代码似乎工作正常,因为日志中记录了以下语句:"succed to build FirebaseModelInterpreter",这意味着 onSuccessListener 工作正常。之后在初始化tensorflow lite runtime时出现问题,错误是libc错误,似乎起源于OS级别,显然是由于某些非法内存访问。在我看来,这只能归因于 tensorflow-lite 库本身。您可以尝试使用不同版本的库或不同的设备,但我不能确定。
在 gradle 文件中:
尝试更改
实施'org.tensorflow:tensorflow-lite:2.0.0'
至
实施'org.tensorflow:tensorflow-lite:+'
我正在做我的 android 项目。基本上,用户输入一段文本,然后模型预测它是否具有冒犯性。这是通过在 python 上训练深度学习模型 LSTM 完成的。然后我将它部署到云端 (Firebase)。并将其下载到我的 android phone 中,如果已下载,则从远程模型创建一个解释器。现在,当我尝试 运行 应用程序时,模型是从云端下载的,但它给出了一个错误。错误消息的 PFA 屏幕截图。 让我知道我做错了什么以及为什么会出现这样的错误?
这是我运行应用程序时得到的日志,
$ adb shell am start -n "com.example.fyp_screens/com.example.fyp_screens.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 32675 on device 'infinix-infinix_hot_4_pro-02576117BM001236'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/skia: SkJpegCodec::onGetPixels +
D/skia: SkJpegCodec::onGetPixels -
I/art: Enter while loop.
I/art: Enter while loop.
I/art: Enter while loop.
I/art: Enter while loop.
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@c10efc6[]
D/WindowClient: Add to mViews: DecorView@c10efc6[MainActivity], this = android.view.WindowManagerGlobal@94c3ad1
D/OpenGLRenderer: Dumper init 2 threads <0x74c0298880>
<com.example.fyp_screens> is running.
D/OpenGLRenderer: CanvasContext() 0x74c4eda000
D/GraphicBuffer: register, handle(0x74c0305540) (w:896 h:1024 s:896 f:0x1 u:0x000100)
D/ViewRootImpl[MainActivity]: hardware acceleration is enabled, this = ViewRoot{e06e936 com.example.fyp_screens/com.example.fyp_screens.MainActivity,ident = 0}
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{e06e936 com.example.fyp_screens/com.example.fyp_screens.MainActivity,ident = 0}, this = DecorView@c10efc6[MainActivity]
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = ViewRoot{e06e936 com.example.fyp_screens/com.example.fyp_screens.MainActivity,ident = 0}, this = DecorView@c10efc6[MainActivity]
D/statusbar color: isDarkStatusBar======false
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@a5f9058[]
D/WindowClient: Add to mViews: DecorView@a5f9058[HomeScreen], this = android.view.WindowManagerGlobal@94c3ad1
D/OpenGLRenderer: CanvasContext() 0x74c4edd800
D/ViewRootImpl[HomeScreen]: hardware acceleration is enabled, this = ViewRoot{592f1d7 com.example.fyp_screens/com.example.fyp_screens.HomeScreen,ident = 1}
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{592f1d7 com.example.fyp_screens/com.example.fyp_screens.HomeScreen,ident = 1}, this = DecorView@a5f9058[HomeScreen]
D/Surface: Surface::allocateBuffers(this=0x74cb854e00)
D/OpenGLRenderer: CanvasContext() 0x74c4edd800 initialize window=0x74cb854e00, title=com.example.fyp_screens/com.example.fyp_screens.HomeScreen
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
D/OpenGLRenderer: Created EGL context (0x74c4eb1280)
D/OpenGLRenderer: ProgramCache.init: enable enhancement 1
I/OpenGLRenderer: Get disable program binary service property (0)
Initializing program atlas...
I/ProgramBinary/Service: ProgramBinaryService client side disable debugging.
ProgramBinaryService client side disable binary content debugging.
D/ProgramBinary/Service: BpProgramBinaryService.getReady
D/ProgramBinary/Service: BpProgramBinaryService.getProgramBinaryData
I/OpenGLRenderer: Program binary detail: Binary length is 182828, program map length is 124.
I/OpenGLRenderer: Succeeded to mmap program binaries. File descriptor is 66, and path is /dev/ashmem.
No need to use file discriptor anymore, close fd(66).
D/OpenGLRenderer: Initializing program cache from 0x0, size = -1
D/MALI: eglCreateImageKHR:513: [Crop] 0 0 896 1024 img[896 1024]
D/Surface: Surface::connect(this=0x74cb854e00,api=1)
W/libEGL: [ANDROID_RECORDABLE] format: 1
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
D/OpenGLRenderer: CacheTexture 5 upload: x, y, width height = 0, 0, 109, 388
ProgramCache.generateProgram: 0
D/GraphicBuffer: register, handle(0x74afeb0680) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/OpenGLRenderer: ProgramCache.generateProgram: 1
D/OpenGLRenderer: ProgramCache.generateProgram: 34359738368
D/OpenGLRenderer: ProgramCache.generateProgram: 5242944
D/OpenGLRenderer: ProgramCache.generateProgram: 34359738371
D/OpenGLRenderer: ProgramCache.generateProgram: 240518168576
D/OpenGLRenderer: ProgramCache.generateProgram: 68719476736
D/GraphicBuffer: register, handle(0x74affbbd40) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
V/InputMethodManager: onWindowFocus: androidx.appcompat.widget.AppCompatEditText{e3bbf6 VFED..CL. .F....ID 60,364-660,455 #7f07003d app:id/editText} softInputMode=288 first=true flags=#81810100
I/Choreographer: Skipped 58 frames! The application may be doing too much work on its main thread.
D/GraphicBuffer: register, handle(0x74affbc940) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/ContentValues: Created a Custom Image Classifier.
D/ContentValues: Configured input & output data for the custom image classifier.
D/statusbar color: isDarkStatusBar======false
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@d37e0bb[]
D/WindowClient: Add to mViews: DecorView@d37e0bb[result1], this = android.view.WindowManagerGlobal@94c3ad1
D/OpenGLRenderer: CanvasContext() 0x74c4ee1000
D/ViewRootImpl[result1]: hardware acceleration is enabled, this = ViewRoot{251037f com.example.fyp_screens/com.example.fyp_screens.result1,ident = 2}
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{251037f com.example.fyp_screens/com.example.fyp_screens.result1,ident = 2}, this = DecorView@d37e0bb[result1]
D/OpenGLRenderer: CanvasContext() 0x74c4ee1000 initialize window=0x74cb855c00, title=com.example.fyp_screens/com.example.fyp_screens.result1
D/Surface: Surface::allocateBuffers(this=0x74cb855c00)
D/Surface: Surface::connect(this=0x74cb855c00,api=1)
W/libEGL: [ANDROID_RECORDABLE] format: 1
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
D/OpenGLRenderer: CacheTexture 5 upload: x, y, width height = 0, 0, 176, 452
D/GraphicBuffer: register, handle(0x74affdc440) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/OpenGLRenderer: ProgramCache.generateProgram: 8899172237312
D/OpenGLRenderer: ProgramCache.generateProgram: 8830452760576
D/OpenGLRenderer: ProgramCache.generateProgram: 8796093022211
D/OpenGLRenderer: ProgramCache.generateProgram: 8830452760579
I/art: Enter while loop.
I/art: Do partial code cache collection, code=15KB, data=25KB
I/art: After code cache collection, code=15KB, data=25KB
Increasing code cache capacity to 128KB
D/GraphicBuffer: register, handle(0x74c4e16980) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
V/InputMethodManager: onWindowFocus: null softInputMode=288 first=true flags=#81810100
D/GraphicBuffer: register, handle(0x74af4a7cc0) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
D/Surface: Surface::disconnect(this=0x74cb854e00,api=1)
D/GraphicBuffer: unregister, handle(0x74affbbd40) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
unregister, handle(0x74affbc940) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/GraphicBuffer: unregister, handle(0x74afeb0680) (w:720 h:1280 s:720 f:0x1 u:0x000b00)
D/Surface: Surface::disconnect(this=0x74cb854e00,api=1)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = ViewRoot{592f1d7 com.example.fyp_screens/com.example.fyp_screens.HomeScreen,ident = 1}, this = DecorView@a5f9058[HomeScreen]
D/libc-netbsd: getaddrinfo: mlkit.googleapis.com get result from proxy gai_error = 0
I/System.out: [socket][0] connection mlkit.googleapis.com/172.217.19.170:443;LocalPort=-1(2000)
D/: [Posix_connect Debug]Process com.example.fyp_screens :443
I/System.out: [socket][/192.168.1.5:55721] connected
D/NativeCrypto: ssl=0x74c4e52480 NativeCrypto_SSL_do_handshake fd=0x74b1903a28 shc=0x74b1903a2c timeout_millis=0 client_mode=1 npn=0x0
D/NativeCrypto: ssl=0x74c4e52480 info_callback calling handshakeCompleted
D/NativeCrypto: ssl=0x74c4e52480 cert_verify_callback => 1
D/NativeCrypto: ssl=0x74c4e52480 NativeCrypto_SSL_get_certificate => NULL
I/System.out: [OkHttp] sendRequest>>
I/System.out: [OkHttp] sendRequest<<
D/NativeCrypto: ssl=0x74c4e52480 info_callback calling handshakeCompleted
I/ModelDownloadManager: Didn't schedule download for the updated model
E/ContentValues: succed to build FirebaseModelInterpreter.
I/art: Enter while loop.
I/tflite: Initialized TensorFlow Lite runtime.
***A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x70 in tid 349 (FirebaseMLHandl)***
这是 lstm-classifier 的代码,
public lstmClassifier(final Context context) throws FirebaseMLException {
final FirebaseCustomRemoteModel remoteModel =
new FirebaseCustomRemoteModel.Builder("offense-detector").build();
final FirebaseModelManager firebaseModelManager = FirebaseModelManager.getInstance();
firebaseModelManager
.isModelDownloaded(remoteModel)
.continueWithTask(
new Continuation<Boolean, Task<Void>>() {
@Override
public Task<Void> then(@NonNull Task<Boolean> task) throws Exception {
// Create update condition if model is already downloaded,
// otherwise create download
// condition.
FirebaseModelDownloadConditions conditions =
task.getResult()
? new FirebaseModelDownloadConditions.Builder()
.requireWifi()
.build() // Update condition that requires wifi.
: new FirebaseModelDownloadConditions.Builder()
.build(); // Download condition.
return firebaseModelManager.download(remoteModel, conditions);
}
})
.addOnSuccessListener(
new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void ignored) {
FirebaseModelInterpreterOptions interpreterOptions =
new FirebaseModelInterpreterOptions.Builder(
new FirebaseCustomRemoteModel.Builder("offense-detector").build())
.build();
try {
interpreter =
FirebaseModelInterpreter.getInstance(interpreterOptions);
Log.e(TAG, "succed to build FirebaseModelInterpreter. ");
} catch (FirebaseMLException e) {
Log.e(TAG, "Failed to build FirebaseModelInterpreter. ", e);
}
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception ignored) {
Toast.makeText(
context,
"Model download failed for image classifier, please check" +
" your connection.",
Toast.LENGTH_LONG)
.show();
}
});
Log.d(TAG, "Created a Custom Image Classifier.");
int[] inputDims = {1, 200};
int[] outputDims = {1,1};
dataOptions =
new FirebaseModelInputOutputOptions.Builder()
.setInputFormat(0, FirebaseModelDataType.INT32, inputDims)
.setOutputFormat(0, FirebaseModelDataType.FLOAT32, outputDims)
.build();
Log.d(TAG, "Configured input & output data for the custom image classifier.");
}//constructor
这似乎是tensorflow-lite 库内部问题。您的代码似乎工作正常,因为日志中记录了以下语句:"succed to build FirebaseModelInterpreter",这意味着 onSuccessListener 工作正常。之后在初始化tensorflow lite runtime时出现问题,错误是libc错误,似乎起源于OS级别,显然是由于某些非法内存访问。在我看来,这只能归因于 tensorflow-lite 库本身。您可以尝试使用不同版本的库或不同的设备,但我不能确定。
在 gradle 文件中:
尝试更改
实施'org.tensorflow:tensorflow-lite:2.0.0'
至
实施'org.tensorflow:tensorflow-lite:+'