google-ai-edge / mediapipe-samples

Apache License 2.0
1.67k stars 426 forks source link

Image Generation Sample Produces 512x512 black image #435

Closed probable1333 closed 3 months ago

probable1333 commented 3 months ago

Device: Galaxy S24+ Exynos 2400 Models tried: runwayml/stable-diffusion-v1-5 and hakurei/waifu-diffusion-v1-4 both converted on Google Colab by following the tutorial and tried to generate images with the demo code in this repo. I am unsure if it is relevant, but the conversion script gave the following warning: /content/convert.py:42: RuntimeWarning: overflow encountered in cast v.numpy().astype("float16").tofile(output_bin_file)

I have added the relevant logs and screenshot as attachments. Thank you. img

logcat.txt

sl33pyC01E commented 3 months ago

Hi hi, I am not a dev but I'm working on the same sample as you. I have a OnePlus12 with Snapdragon8gen2 and 16GB ram. Using the default settings causes my app to crash on "initialize" due to a memory overflow in the GPU.

I would suggest dropping your resolution to 448x448 (512-64=448) additionally, here is the prebuilt apk that's available: https://storage.googleapis.com/mediapipe-tasks/image_generator/imagegenerator.apk

I can't figure out how to avoid the memory overflow on my phone but the prebuilt works at low resolutions.

probable1333 commented 3 months ago

Hi, thank you for the suggestion. I am glad that you managed to get it working. I have given it a try with the APK you have provided, but unfortunately I still get pure black result. I have also tried a couple of more tries down to 128x128 to no avail. With the GPU Watch tool of Samsung, I can see that the GPU is used 100% during inference, so it does seem to do something at least.

probable1333 commented 3 months ago

Closing due to #5589