I have a js script that exports a video frame to a temp canvas, then passes the frame image to a python script using ajax and php.
The python script then extracts the players and ball from the frame and outputs a transparent png which is returned to my application using the following modules:
import argparse,os
import numpy as np
import bisect
import matplotlib.pyplot as plt
import tensorflow.compat.v1 as tf_v1
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import backend as K
import os
import cv2
import math
When the python script executes, it takes about 25 seconds to produce an output png because I am doing this on a virtual machine without a supported GPU.
I am thinking that I could potentially speed up execution by making the python script run as a service, because when the script loads each time it has to pull in a 250mb model file.
Currently, i use php to shell execute my python command line:
python extract-players.py --input input.jpg --output output.png --player_model player_model.pb --ball_model ball_model.h5 --classes classes.pbtxt --thr 0.5
I then grab the output.png and store it as a new image().
I'm just wondering if anyone has used python or tensorflow as a service before, and more so how would I call the service to pass in video frame image?