Commit Graph

674 Commits

Author SHA1 Message Date
Camillo Lugaresi
3c53ec2cdb Do not expose DrishtiGraphGPUData.h in public header
This class is an implementation detail.

PiperOrigin-RevId: 490530823
2022-11-23 10:11:32 -08:00
MediaPipe Team
b5189758f7 Move ImagePreprocessing to "processors" folder.
PiperOrigin-RevId: 490444821
2022-11-23 02:08:37 -08:00
Sebastian Schmidt
c5ce523697 Add cosine APIs to Embedder tasks
PiperOrigin-RevId: 490444597
2022-11-23 02:04:44 -08:00
Sebastian Schmidt
05681fc0e1 Internal
PiperOrigin-RevId: 490439195
2022-11-23 01:29:37 -08:00
Camillo Lugaresi
a55839de51 This storage only needs a "done writing" callback on simulator, so only set it there
- When not on simulator, we pass nullptr instead of a do-nothing callback.
- The callback is no longer a method, but a function. Only the CVPixelBuffer is captured.

PiperOrigin-RevId: 490380248
2022-11-22 18:09:09 -08:00
Sebastian Schmidt
3bbc0e9af9 Internal change
PiperOrigin-RevId: 490375672
2022-11-22 17:39:54 -08:00
MediaPipe Team
837225c53d Internal change
PiperOrigin-RevId: 490374976
2022-11-22 17:36:15 -08:00
Camillo Lugaresi
8ba9d87e66 Update ImageFrameToGpuBufferCalculator to use api2 and GpuBuffer conversions
PiperOrigin-RevId: 490374387
2022-11-22 17:32:33 -08:00
MediaPipe Team
fac97554df Small TS audio API improvement
PiperOrigin-RevId: 490374083
2022-11-22 17:27:47 -08:00
Camillo Lugaresi
efa9e737f8 Use current context if available in ConvertToImageFrame
If we're already running in a GlContext, there's no need to go back to the producer context, which may be different.

PiperOrigin-RevId: 490373829
2022-11-22 17:24:03 -08:00
MediaPipe Team
7ce4aa6592 Internal change
PiperOrigin-RevId: 490366250
2022-11-22 16:40:38 -08:00
Camillo Lugaresi
515d00fc22 Internal change
PiperOrigin-RevId: 490349260
2022-11-22 15:18:21 -08:00
vrabaud
872d1afda7 Internal change
PiperOrigin-RevId: 490196129
2022-11-22 03:12:38 -08:00
Camillo Lugaresi
d648926155 Just reset the fb binding to 0 in ReadTexture
This saves a get operation. We already have precedent in lots of other MediaPipe code where we just reset bindings to 0.

PiperOrigin-RevId: 490170691
2022-11-22 00:36:54 -08:00
Camillo Lugaresi
bacbac8d92 Use kUtilityFramebuffer in ReadTexture
This avoids creating a temporary framebuffer each time.

PiperOrigin-RevId: 490163892
2022-11-21 23:59:44 -08:00
Camillo Lugaresi
a8b7761022 Define a kUtilityFramebuffer context attachment
A framebuffer object is often needed to render to a texture or read data from it. Currently we create one in each GlCalculatorHelper, but that is redundant (we only need one per context, and multiple calculators can share the same context). Other times, the code that needs to use this doesn't own a helper. For both reasons, this should be attached to the context.

We could just make this a member of GlContext since it's so common. However, I figured we might as well use the attachment system.

PiperOrigin-RevId: 490160214
2022-11-21 23:29:27 -08:00
Camillo Lugaresi
54a684717f Internal change
PiperOrigin-RevId: 490159674
2022-11-21 23:24:16 -08:00
MediaPipe Team
d43d0ff615 Internal change
PiperOrigin-RevId: 490089940
2022-11-21 15:47:45 -08:00
MediaPipe Team
adddf2c2ab Extracted common test helper functions out from the unittest into a sharable
library. Also migrated away from OpenCVX.

PiperOrigin-RevId: 490074410
2022-11-21 14:39:56 -08:00
MediaPipe Team
652423a23d Internal change
PiperOrigin-RevId: 490053179
2022-11-21 13:06:47 -08:00
MediaPipe Team
7f0134eecb Internal change
PiperOrigin-RevId: 490041386
2022-11-21 12:16:00 -08:00
MediaPipe Team
7acbf557a1 Cleanup after migration to new classification output format.
PiperOrigin-RevId: 489921603
2022-11-21 01:57:05 -08:00
MediaPipe Team
13c6b9a8c6 Allow kernel cache path to be specified without trailing path delimiter
PiperOrigin-RevId: 489891079
2022-11-20 22:20:18 -08:00
Camillo Lugaresi
3ac7f6a216 Simplify image creation in PacketCreator
Use more existing functions, remove redundant code, remove direct use of RuntimeException.

PiperOrigin-RevId: 489868983
2022-11-20 19:32:21 -08:00
MediaPipe Team
6cf464636b Internal change
PiperOrigin-RevId: 489842199
2022-11-20 14:26:22 -08:00
Scott Zhu
a367753eda Internal change
PiperOrigin-RevId: 489824381
2022-11-20 10:41:20 -08:00
MediaPipe Team
bdf4078e89 Internal change
PiperOrigin-RevId: 489752009
2022-11-19 21:14:24 -08:00
Camillo Lugaresi
a33cb1e05e Check that Java buffer supports direct access before using it
If the buffer is not created with allocateDirect, JNI APIs will return a data pointer of nullptr and a capacity of -1. This can cause a crash when we access it.

Also clean up the code to raise exceptions instead of just logging errors and returning nullptr.

PiperOrigin-RevId: 489751312
2022-11-19 21:04:48 -08:00
MediaPipe Team
977ee4272e Add public visibility to the model maker public API.
PiperOrigin-RevId: 489701768
2022-11-19 10:53:21 -08:00
Sebastian Schmidt
bbcbd5fc6c Audio Embedder for Web
PiperOrigin-RevId: 489669966
2022-11-19 04:49:24 -08:00
Sebastian Schmidt
e853f04b79 Create AudioTaskRunner
PiperOrigin-RevId: 489613573
2022-11-18 19:55:08 -08:00
Camillo Lugaresi
eb8ef1ace0 Use shared_from_this in GlTextureBuffer::GetReadView, GetWriteView
This ensures that the callbacks in GlTextureView won't call an expired object, even if user code holds a GlTextureView after releasing the buffer.

Note that GlTextureBuffer is not always held by a shared_ptr, but it always is when GpuBuffer calls GetRead/WriteView on it. An alternative solution would have been to have GpuBuffer pass its shared_ptr<GlTextureBuffer> to the view method, which could have been implemented with some compile-time logic to detect whether the method expects such an argument. However, that doesn't seem necessary.

PiperOrigin-RevId: 489611843
2022-11-18 19:42:34 -08:00
MediaPipe Team
bbd5da7971 Added the gray scale image support for the ImageToTensorCalculator on CPU.
PiperOrigin-RevId: 489593917
2022-11-18 17:12:57 -08:00
MediaPipe Team
524ac3ca61 Internal change for Model Maker
PiperOrigin-RevId: 489540387
2022-11-18 12:48:30 -08:00
Jiuqiang Tang
1b594a0310 Return error status when any tflite input and output tensor doesn't have valid dimensionality information that is needed to allocate Gl/Metal buffer before calling ModifyGraphWithDelegate.
PiperOrigin-RevId: 489539740
2022-11-18 12:44:55 -08:00
Sebastian Schmidt
71ae496a20 Add AudioEmbedder documentation
PiperOrigin-RevId: 489532283
2022-11-18 12:12:41 -08:00
MediaPipe Team
e2052a6a51 Rename embedding postprocessor "configure" method for consistency with classification postprocessor.
PiperOrigin-RevId: 489518257
2022-11-18 11:13:10 -08:00
Adam Cozzette
ac212c1507 Internal change
PiperOrigin-RevId: 489502255
2022-11-18 10:08:26 -08:00
MediaPipe Team
03d388fecf Add hand landmark named index constants
PiperOrigin-RevId: 489498248
2022-11-18 09:52:44 -08:00
MediaPipe Team
2f361e2f47 Internal change
PiperOrigin-RevId: 489486417
2022-11-18 08:53:43 -08:00
Jiuqiang Tang
e046982a3c Internal change
PiperOrigin-RevId: 489484898
2022-11-18 08:47:09 -08:00
Hadon Nash
ae44012c0c Allowing BypassCalculator to accept InputSidePackets.
PiperOrigin-RevId: 489483992
2022-11-18 08:43:02 -08:00
Camillo Lugaresi
efcdedbd59 Remove redundant _ios targets
PiperOrigin-RevId: 489355333
2022-11-17 18:16:58 -08:00
Copybara-Service
cd056e114a Merge pull request #3866 from kinaryml:fix-tasks-api-python-311-errors
PiperOrigin-RevId: 489346167
2022-11-17 17:20:23 -08:00
MediaPipe Team
6f3cb340e1 Internal change
PiperOrigin-RevId: 489345940
2022-11-17 17:16:25 -08:00
MediaPipe Team
ab3a5f0fbf Make MuxCalculator with DefaultInputStreamHandler to handle graph closure gracefully
PiperOrigin-RevId: 489336722
2022-11-17 16:30:35 -08:00
MediaPipe Team
a7bd725e65 Internal change
PiperOrigin-RevId: 489331826
2022-11-17 16:09:15 -08:00
MediaPipe Team
1fb0902aa0 Update gesture_recognizer test
PiperOrigin-RevId: 489301508
2022-11-17 14:04:30 -08:00
Sebastian Schmidt
3ccf7308e0 Add shared options for Text and Audio Tasks
PiperOrigin-RevId: 489186644
2022-11-17 05:28:27 -08:00
Hadon Nash
ea4989b6f1 Internal change
PiperOrigin-RevId: 489135553
2022-11-17 00:07:59 -08:00
kinaryml
5a6837d034 Fix errors that will occur in python 3.11 2022-11-16 22:08:52 -08:00
Sebastian Schmidt
899c87466e Add MP Tasks entrypoints
PiperOrigin-RevId: 489110875
2022-11-16 20:57:33 -08:00
Camillo Lugaresi
6fc277ee1c Internal change
PiperOrigin-RevId: 489091534
2022-11-16 18:38:03 -08:00
Sebastian Schmidt
e66e88802c Change NPM Bundle to ESM
PiperOrigin-RevId: 489091370
2022-11-16 18:34:53 -08:00
MediaPipe Team
90eb4a19d8 Internal change
PiperOrigin-RevId: 489088227
2022-11-16 18:16:32 -08:00
MediaPipe Team
b6b72d5e4e Add MuxCalculator test case where graph is being closed while SELECT has not been received.
PiperOrigin-RevId: 489061902
2022-11-16 15:56:43 -08:00
Sebastian Schmidt
3cdf0f6536 Fix a crash that occurred when a model returns fewer vector elements than before
PiperOrigin-RevId: 489041814
2022-11-16 14:38:37 -08:00
MediaPipe Team
74474d859e Update image_classifier demo with new ImageClassifierOption changes
PiperOrigin-RevId: 489031381
2022-11-16 14:00:39 -08:00
MediaPipe Team
cdd44e77b7 Internal change
PiperOrigin-RevId: 488969539
2022-11-16 10:07:40 -08:00
MediaPipe Team
dc9578d226 Internal change
PiperOrigin-RevId: 488946809
2022-11-16 08:30:20 -08:00
Sebastian Schmidt
f7aef677fc Add running mode to all vision tasks
PiperOrigin-RevId: 488816785
2022-11-15 19:02:21 -08:00
Camillo Lugaresi
febfc2029b Annotate plane argument
PiperOrigin-RevId: 488813363
2022-11-15 18:53:09 -08:00
Camillo Lugaresi
63e2089639 Deprecate a bunch of old stuff in GlCalculatorHelper
PiperOrigin-RevId: 488813296
2022-11-15 18:51:56 -08:00
Camillo Lugaresi
1979801a92 Remove GlCalculatorHelperImpl; merge with GlCalculatorHelper
Originally, there were multiple implementations of GlCalculatorHelperImpl, depending on the platform and underlying GL APIs. These have all been refactored into other components, and the remaining code in this class is unified and much reduced in size. We can get rid of this implementation detail now.

PiperOrigin-RevId: 488813220
2022-11-15 18:50:45 -08:00
Camillo Lugaresi
8b319e963a Add comment explaining ViewProvider
This was only documented via examples (e.g. ViewProvider<GlTextureView>), but it's better to explain it properly in the header where the base case is defined.

PiperOrigin-RevId: 488813144
2022-11-15 18:48:54 -08:00
Camillo Lugaresi
a28ccb0964 Remove unnecessary forward declarations
PiperOrigin-RevId: 488813066
2022-11-15 18:43:36 -08:00
Camillo Lugaresi
13b4b825d7 Remove std::shared_ptr<GpuBuffer> argument from GetRead/WriteView
PiperOrigin-RevId: 488813004
2022-11-15 18:41:53 -08:00
Camillo Lugaresi
1c0a1d0aab Remove shared_ptr<GpuBuffer> member from GlTextureView
This only exists to support GlTexture's GetFrame API. It can be moved into GlTexture.

PiperOrigin-RevId: 488812896
2022-11-15 18:40:15 -08:00
Camillo Lugaresi
767cc2ee3c More comments on gpu_buffer_storage
This gives a basic explanation of the role of storages and views, and provides some details on how to implement a new storage type.

PiperOrigin-RevId: 488812807
2022-11-15 18:38:29 -08:00
Camillo Lugaresi
4c874fe4cd Allow conversion of GlTextureBuffer to CVPixelBufferRef
This means that, if an iOS application sends in a GlTextureBuffer but expects a CVPixelBufferRef as output, everything will work even if the graph just forwards the same input. Also, access by Metal calculators will also work transparently.

PiperOrigin-RevId: 488812748
2022-11-15 18:36:45 -08:00
Camillo Lugaresi
fe66de3714 Internal change
PiperOrigin-RevId: 488812677
2022-11-15 18:32:54 -08:00
MediaPipe Team
2f77bf44e3 Use train_data to evaluate accuracy of unit test for gesture_recognizer due to limited dataset size.
PiperOrigin-RevId: 488808942
2022-11-15 18:10:28 -08:00
Camillo Lugaresi
b308c0dd5e Implement CVPixelBufferRef access as a view.
PiperOrigin-RevId: 488798216
2022-11-15 17:18:07 -08:00
Camillo Lugaresi
4bda012bba Factor out gl_texture_util
PiperOrigin-RevId: 488797985
2022-11-15 17:13:22 -08:00
Camillo Lugaresi
77b3edbb67 Internal change
PiperOrigin-RevId: 488797407
2022-11-15 17:09:43 -08:00
Camillo Lugaresi
7e19bbe35c Internal change
PiperOrigin-RevId: 488795920
2022-11-15 17:01:33 -08:00
Camillo Lugaresi
1beca61650 Register GlTextureBuffer pool with GpuBuffer
First crack at hooking up pools with the GpuBufferStorage system. Will most likely be superseded later, but for now this works with minimal code impact: just overwrite the factory for a storage type with one that uses the pool.

PiperOrigin-RevId: 488783854
2022-11-15 16:19:48 -08:00
Camillo Lugaresi
583d27636b Factor out ReusablePool
PiperOrigin-RevId: 488783477
2022-11-15 16:18:20 -08:00
Camillo Lugaresi
53d015af08 Generic MultiPool template
PiperOrigin-RevId: 488783176
2022-11-15 16:15:42 -08:00
Camillo Lugaresi
b9fa2e3496 Make it possible to override the SimplePool factory used by MultiPool
This means MultiPool no longer needs a SetFlushPlatformCaches method, which was too specific to the CVPixelBufferPool.

PiperOrigin-RevId: 488783003
2022-11-15 16:14:27 -08:00
Camillo Lugaresi
267476657d MultiPool options header refactoring
Passing MultiPool options to the base pool factories means that we don't have to specialize which options we pass to them.

PiperOrigin-RevId: 488782861
2022-11-15 16:13:05 -08:00
Camillo Lugaresi
7ef3185ecb Allow customizing MultiPool options
These don't need to be constants.

PiperOrigin-RevId: 488782713
2022-11-15 16:11:54 -08:00
Camillo Lugaresi
f13903b7c5 Call SimplePool methods directly
This removes redundant helper functions in GpuBufferMultiPool.

PiperOrigin-RevId: 488782516
2022-11-15 16:10:34 -08:00
Camillo Lugaresi
0c4522cb9f Move flush hook to CvPixelBufferPoolWrapper constructor
This unifies the implementation of GpuBufferMultiPool::GetBufferFromSimplePool.

PiperOrigin-RevId: 488782173
2022-11-15 16:07:17 -08:00
Camillo Lugaresi
a4fe3eb094 Add CreateBufferWithoutPool method to base pools
This may not fit exactly in a pool class, but it makes it easy for the multi-pool to find the appropriate method by depending only on the type of the base pool. For the CVPixelBuffer case, the buffer type is CFHolder<CVPixelBufferRef>, and it seems even less appropriate to specialize that template to add such a method there. An alternative would be to allow defining a creation function separately.

PiperOrigin-RevId: 488782054
2022-11-15 16:05:53 -08:00
Camillo Lugaresi
0d273dd11a Factor out CvPixelBufferPoolWrapper
This is platform-specific and does not need to live in the main multi_pool sources.

PiperOrigin-RevId: 488781934
2022-11-15 16:04:27 -08:00
Camillo Lugaresi
ab2dd779e7 Factor out CvTextureCacheManager
This is a platform-specific component that is only used with CVPixelBufferPool.

PiperOrigin-RevId: 488781757
2022-11-15 16:02:53 -08:00
MediaPipe Team
fae55910f4 Enable absl::string_view kCalculatorName
PiperOrigin-RevId: 488781493
2022-11-15 15:59:09 -08:00
Camillo Lugaresi
a520d6cc38 Remove FORCE_CONTIGUOUS_PIXEL_BUFFER_ON_IPHONE_SIMULATOR
This workaround code is no longer necessary, as per the comment.

PiperOrigin-RevId: 488777606
2022-11-15 15:41:53 -08:00
Camillo Lugaresi
3c71c64be1 Remove shared_ptr from SimplePool definition
This makes the types more explicit and will help with factoring out platform-specific code.

PiperOrigin-RevId: 488775470
2022-11-15 15:32:57 -08:00
Camillo Lugaresi
a67069156e Use flat_hash_map in ResourceCache
This is the recommended hashmap in most cases.

PiperOrigin-RevId: 488772031
2022-11-15 15:23:31 -08:00
MediaPipe Team
38b636f7ee Internal change
PiperOrigin-RevId: 488770794
2022-11-15 15:19:48 -08:00
Camillo Lugaresi
7a87546c30 Internal change
PiperOrigin-RevId: 488761646
2022-11-15 14:39:58 -08:00
MediaPipe Team
e65f21e2d8 Update the docstring to make it consistent with the model option update.
PiperOrigin-RevId: 488761331
2022-11-15 14:36:48 -08:00
Sebastian Schmidt
496720308c Migrate remaining MP Tasks Libraries to ts_declarations
PiperOrigin-RevId: 488752799
2022-11-15 14:08:15 -08:00
MediaPipe Team
1689112b23 Improve model_util_test code.
PiperOrigin-RevId: 488752497
2022-11-15 14:04:39 -08:00
MediaPipe Team
f14645cb06 Model maker gesture recognizer test changes
PiperOrigin-RevId: 488702055
2022-11-15 10:50:32 -08:00
MediaPipe Team
ebba119f15 Add Java ImageEmbedder API.
PiperOrigin-RevId: 488588010
2022-11-15 01:26:00 -08:00
Camillo Lugaresi
6f54308c25 Internal change
PiperOrigin-RevId: 488552135
2022-11-14 21:42:41 -08:00
Jiuqiang Tang
87dff8142c Fix a typo.
PiperOrigin-RevId: 488519113
2022-11-14 18:13:50 -08:00