google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.44k stars 5.15k forks source link

Executing ImageGenerator.createFromOptions crashes the program #5222

Open ZTMIDGO opened 7 months ago

ZTMIDGO commented 7 months ago

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

None

OS Platform and Distribution

Android 14

Mobile device if the issue happens on mobile device

Xiaomi Redmi Note 12 Turbo

Browser and version if the issue happens on browser

No response

Programming Language and version

Java

MediaPipe version

com.google.mediapipe:tasks-vision-image-generator:latest.release

Bazel version

No response

Solution

ImageGenerator

Android Studio, NDK, SDK versions (if issue is related to building in Android environment)

No response

Xcode & Tulsi version (if issue is related to building for iOS)

No response

Describe the actual behavior

An exception occurs when createFromOptions is executed

Describe the expected behaviour

An instance of the ImageGenerator should be obtained

Standalone code/steps you may have used to try to get what you need

new Thread(new Runnable() {
                    @Override
                    public void run() {
                        String path = getFilesDir().getAbsolutePath()+"/bins";
                        ImageGenerator.ImageGeneratorOptions options = ImageGenerator.ImageGeneratorOptions.builder().setImageGeneratorModelDirectory(path).build();
                        ImageGenerator helper = ImageGenerator.createFromOptions(MainActivity.this.getApplicationContext(), options);
                    }
                }).start();

Other info / Complete Logs

11:45:19.622  E  E0000 00:00:1710301519.622072    6442 diffuser_gpu.cc:88] UNKNOWN: Failed to create 2D texture (clCreateImage): Invalid image size
11:45:19.622  E  E0000 00:00:1710301519.622527    6439 calculator_graph.cc:887] INTERNAL: CalculatorGraph::Run() failed: 
                 Calculator::Open() for node "mediapipe_tasks_vision_image_generator_imagegeneratorgraph__StableDiffusionIterateCalculator" failed: ; RET_CHECK failure (mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator.cc:248) context_
11:45:19.624  E  FATAL EXCEPTION: Thread-6
                 Process: com.soya.demosd, PID: 5328
                 com.google.mediapipe.framework.MediaPipeException: internal: CalculatorGraph::Run() failed: 
                 Calculator::Open() for node "mediapipe_tasks_vision_image_generator_imagegeneratorgraph__StableDiffusionIterateCalculator" failed: ; RET_CHECK failure (mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator.cc:248) context_
                    at com.google.mediapipe.framework.Graph.nativeWaitUntilGraphIdle(Native Method)
                    at com.google.mediapipe.framework.Graph.waitUntilGraphIdle(Graph.java:464)
                    at com.google.mediapipe.tasks.core.TaskRunner.create(TaskRunner.java:74)
                    at com.google.mediapipe.tasks.vision.imagegenerator.ImageGenerator.createFromOptions(ImageGenerator.java:167)
                    at com.google.mediapipe.tasks.vision.imagegenerator.ImageGenerator.createFromOptions(ImageGenerator.java:96)
                    at com.soya.demosd.MainActivity$1$1.run(MainActivity.java:34)
                    at java.lang.Thread.run(Thread.java:1012)
schmidt-sebastian commented 7 months ago

You are getting an error from OpenCL here. I will route this issue to our GPU team.

cerberspace commented 4 months ago

I have the same error Android GPU Andero 750 2024-07-04 03:25:12.014 28876-28876 ImeTracker I com.google.mediapipe.examples.imagegeneration:46fa34ee: onRequestHide at ORIGIN_CLIENT_HIDE_SOFT_INPUT reason HIDE_SOFT_INPUT 2024-07-04 03:25:12.084 28876-28956 native I I0000 00:00:1720034712.083933 28956 diffuser.cc:81] Environment created 2024-07-04 03:25:14.138 28876-28956 native I I0000 00:00:1720034714.138813 28956 diffuser.cc:89] TextGuidance is created 2024-07-04 03:25:14.152 28876-28956 native I I0000 00:00:1720034714.151973 28956 diffuser.cc:94] Copier is created 2024-07-04 03:25:31.105 28876-28956 native E E0000 00:00:1720034731.105563 28956 diffuser_gpu.cc:88] UNKNOWN: Failed to create 2D texture (clCreateImage): Invalid image size 2024-07-04 03:25:31.106 28876-28953 native E E0000 00:00:1720034731.106050 28953 calculator_graph.cc:887] INTERNAL: CalculatorGraph::Run() failed: Calculator::Open() for node "mediapipe_tasks_vision_image_generator_imagegeneratorgraph__StableDiffusionIterateCalculator" failed: ; RET_CHECK failure (mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iteratecalculator.cc:248) context 2024-07-04 03:25:31.128 28876-28953 AndroidRuntime E FATAL EXCEPTION: DefaultDispatcher-worker-1 Process: com.google.mediapipe.examples.imagegeneration, PID: 28876 com.google.mediapipe.framework.MediaPipeException: internal: CalculatorGraph::Run() failed: Calculator::Open() for node "mediapipe_tasks_vision_image_generator_imagegeneratorgraph__StableDiffusionIterateCalculator" failed: ; RET_CHECK failure (mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iteratecalculator.cc:248) context at com.google.mediapipe.framework.Graph.nativeWaitUntilGraphIdle(Native Method) at com.google.mediapipe.framework.Graph.waitUntilGraphIdle(Graph.java:464) at com.google.mediapipe.tasks.core.TaskRunner.create(TaskRunner.java:74) at com.google.mediapipe.tasks.vision.imagegenerator.ImageGenerator.createFromOptions(ImageGenerator.java:167) at com.google.mediapipe.tasks.vision.imagegenerator.ImageGenerator.createFromOptions(ImageGenerator.java:96) at com.google.mediapipe.examples.imagegeneration.ImageGenerationHelper.initializeImageGenerator(ImageGenerationHelper.kt:32) at com.google.mediapipe.examples.imagegeneration.diffusion.DiffusionViewModel$initializeImageGenerator$3.invokeSuspend(DiffusionViewModel.kt:66) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@8c43678, Dispatchers.Default]