0

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?

Carl Miller
  • 113
  • 2
  • 13
  • 1
    Is this what you are looking for ? https://stackoverflow.com/questions/32404/how-do-you-run-a-python-script-as-a-service-in-windows – Jason Chia Apr 14 '21 at 13:04
  • Hi, yes and no. i'm trying to find how I would pass the image into the service to be computed by tensorflow. I've found something about creating a tensorflow serving server. – Carl Miller Apr 14 '21 at 13:30

0 Answers0