Direct model embedding loads a model and runs prediction inside the user application’s process. Model loading, inference, and application logic remain local, with no communication between processes or remote servers. section 6.2.1
This design fits tightly integrated applications but introduces practical constraints:
- It can support offline or device-local prediction, such as identifying plants from photos in a mobile application. section 6.2.1
- Embedding is difficult when application code uses Go, Java, or C# while model code uses Python; PyTorch and TensorFlow provide C++ libraries, and TensorFlow also provides JavaScript and Java libraries. section 6.2.1
- Large models consume client-device resources and can make applications slower, especially on lower-end hardware. section 6.2.1
- Mixing serving code with business logic complicates backward compatibility, making this approach relatively uncommon. section 6.2.1
Face-swapping mobile application
A face-swapping app can execute its single deepfake model directly in the application process instead of calling a separate predictor service. The alternative design separates the mobile UI, application backend, and model-serving predictor behind a web API. section 6.3.1
Figure 6.5 In the direct model embedding design, the model is executed in the same process as the application logic.
Use the architecture figure to see model execution colocated with application logic in the same process. section 6.3.1
