The WeChat applet runs the Demo of TensorFlow, and the code is updated synchronously with the applet "AI Pocket" from time to time.
Recommended system: MacOS
NodeJS: v18.xx
WeChat basic library version: >= 2.29.0
WeChat developer tools: >= v1.06.2210310
Project configuration of WeChat developer tools:
appid
configuration in project.config.jsonnpm i
installs dependencies (sometimes you may need to use npm i --force
)npm run build
compile dependencies Transform tfjs-core so that TensorFlow.js can run in small programs. The applet calls the camera for imaging and displays the image on canvas
. The "ImageData-like" data of canvas
can be obtained through the applet's API, and then the tfjs API is called to implement prediction.
If you are interested in the bumpy experience of implementation, you can read the blog posts on transplanting tfjs to WeChat applet and trying again on transplanting TensorFlowJS.
Since tfjs has elegantly implemented support for multiple platforms, specifically by extending platform
to achieve "transplantation", and the WeChat applet has also opened up more advantageous APIs, the intrusive way of modifying tfjs is no longer used. It uses the WeChat plug-in of tfjs to provide model loading, training, prediction and other functions.
Although it is much more convenient than before, the frame data obtained by the applet's onCameraFrame
is inconsistent with what is displayed, and the original frame data is processed differently on different devices (even the front and rear cameras of the same device). , it is really daunting to get accurate prediction results.
At present, I have figured out a set of frame data cropping methods and briefly tested them, and the results are good. If there are any models that cannot be taken care of, please submit Issues & PR .
Now the frame data cropping methods of mini programs have become consistent on different platforms.
The mini program has been renamed "AI Pocket". It still feels meaningful, so I plan to make this mini program serious. Attached is the QR code of the mini program. Everyone is welcome to experience it & provide suggestions for improvements!
I have accumulated experience in front-end and back-end development, Docker & Swarm, continuous deployment, and artificial intelligence NLP. I can quickly provide a complete set of solutions. If you have the opportunity, please feel free to inquire about cooperation through various contact methods.
In addition, the code of this project is open source, and interested students are welcome to contribute. Of course, there are no restrictions on commercial use, but please respect the work of others and don't do something "unkind". If this project is helpful to you, please feel free to tip.
You can follow my personal blog or my personal WeChat public account "Hunter Grocery Store". There will often be some technology sharing & life insights. Welcome to communicate!
Follow the official account and leave a message to get the QR code of the "AI Pocket Communication Group" to facilitate communication! ~