Comments (13)
Got it. Supporting YUV conversion utils is in our roadmap. I'll give updates here once we have any progresses.
So far, we only touched image processing on CPU. We have some undergoing projects related to GPU computation, but they are still in an early stage.
from tflite-support.
@lu-wang-g, no worries, thanks for the update!
Perhaps I can ask for a consult. Do you have a suggestion regarding the best approach to pass images from camera to a model with a possible persistence to a JPEG / WebP file? Maybe some team at Google had a similar workflow. Our model consumes RGB bitmaps, we’ve used RenderScript for the YUV → RGB conversion so far. Unfortunately, RenderScript is deprecated (as a tool) — we’ve tried libyuv
as a replacement but it’s a bit less performant. The trick is — we have to persist resulting images in the original resolution (4K) so we cannot request small-ish images from the camera. I guess one approach might be to switch a YUV-consuming model but it will require a retraining and it still might be less performant IRL.
from tflite-support.
@lu-wang-g Hi Lu, Any thoughts on this?
from tflite-support.
Converting to RGB and image rotation are supported in Task library through ImageProcessingOptions
, such as ImageClassifier#classify(TensorImage, ImageProcessingOptions). You don't need to convert it to Bitmap. We're working on publish examples and tutorials to introduce consuming YUV images directly.
Surfacing YUV image conversion to RGB in TensorImage is not prioritized at this moment. We have the C++ implementation, but haven't wrapped it in Java yet. In C++, image processing is done through FrameBuffer. See the code here for an example of how to.
from tflite-support.
@lu-wang-g, thanks for details!
I understand that the Bitmap
becomes kind of redundant but we still need it (for our use case) to save the image as a JPEG file. Maybe it can be done on the native level as well though. We don’t save all images however since not everything is useful. Not sure how popular this scenario is to do the investment but I imagine that saving model-enriched images after their processing is used by someone besides us 😉
from tflite-support.
@arturdryomov I agree with that saving images could be very useful, at least for debugging purposes I can imagine.
If adding implementation to getBitmap
on MediaImageContainer
is all your need, and not very concern about performance, we can add an implementation there (as far as I know, our C++ YUV library is really fast, Java implementation might not be that efficient), but we can not promise a date due to workload.
If you're interested, any contribution is really welcomed!
from tflite-support.
@xunkai55, thanks, this might be useful indeed. In the meanwhile I guess we might want to explore using FrameBuffer
API instead 🤔
from tflite-support.
@lu-wang-g, hey, is there a reason for this issue to be closed? Seems like a valid use case (not of a top priority of course but still).
from tflite-support.
Ha, I thought the issue was walked around by using FrameBuffer. Let me reopen it to track.
from tflite-support.
@lu-wang-g, unfortunately we weren’t able to use FrameBuffer
for this since we didn’t want to pull this repo to get access to header files. We did something with libyuv
which kinda works but it would be useful to have this built-in to avoid dealing with NDK / JNI.
BTW, as a side-note — have you tried using Vulkan for the YUV → RGB conversion? Would be interesting to know if there are benefits.
from tflite-support.
@lu-wang-g, hey, are there news regarding this issue?
from tflite-support.
We had to shift our roadmap on image utils soon after I left my previous comments last year. We won't be able to deliver this feature in the near feature. Sorry about it.
from tflite-support.
Libyuv should be very performant as far as I know. We use it to perform image processing in Task Library as well. Alternatively, you can request RGBA output from CameraX directly. See this blogpost: https://medium.com/androiddevelopers/convert-yuv-to-rgb-for-camerax-imageanalysis-6c627f3a0292.
from tflite-support.
Related Issues (20)
- Modify tflite quantization params
- implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
- Select TensorFlow op(s), included in the given model, is(are) not supported by this interpreter. Make sure you apply/link the Flex delegate before inference. For the Android, it can be resolved by adding "org.tensorflow:tensorflow-lite-select-tf-ops" dependency. See instructions: https://www.tensorflow.org/lite/guide/ops_select
- I want to ask if TFLImage Searcher is supported on iOS and if so, where can I get a sample?
- Getting "Cannot copy to a TensorFlowLite tensor (serving_default_input_1:0) with 63984 bytes from a Java Buffer with 64000 bytes" error while attempting to pass the Input and Output TensorAudio Buffer to TFLite Interpreter for inference HOT 1
- ImportError from image_utils HOT 4
- Could you please provide a aarch64 tflite-support wheel for python 3.10 HOT 2
- YOLOv8 `tensorflow>=2.14.0` ImportError: generic_type: cannot initialize type "StatusCode": an object with that name is already defined HOT 6
- How to read .wav in adroid jni?
- `tf.lite`, or `tflite_tuntime.interpreter as `tflite`?
- TensorFlowLiteTaskAudio for iOS: How to save audio and then play it
- ERROR: Could not find a version that satisfies the requirement tflite-support==0.4.4 HOT 4
- Installation Error: Unable to find installation candidates for tflite-support (0.4.4) HOT 1
- Build TensorFlowLiteTaskVision_framework failed HOT 2
- How to handle dynamic output tensors with `tflite.runForMultipleInputsOutputs`
- iOS Error duplicate symbols HOT 2
- 0.4.2 and 0.4.3 versions of the pod are crashing on app launch on iOS 12.5.7
- Quantization with tflite : Unexpected input data type. Actual: (tensor(float)) , expected: (tensor(int8))
- How to install tflite_support in pip by source compiling HOT 3
- Possibility of channel-by-channel image normalization when adding metadata
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tflite-support.