Is there any method to accelerate the transferring single image time between client and server?

Viewed 98

I wanna speed up the transferring time of single image between client and server. (i.e., different devices)

Left hand side was to sending an image (2.8MB png) from A to B then getting the results from B to A. It takes 300ms totally. Right hand side was to do on local only. It still need to take 30ms. (It was tested by internal network.)

my experiments tested on local and remote.

The server was built by python flask framework. I am looking for a method which is able to get a really really fast way (or any frameworks) to transfer an image between 2 devices? In my case, I pay more attention on transferring time (efficiency)

Here is my simple code

on client side

import requests
import time

start = time.time()
files  = {'file': open('test.png', 'rb')}

url = 'http://(server ip):5999/test'

myobj = {'data': 'key1'}
result  = requests.post(url, files=files)
print(result.json())
print("Total time: ", time.time()-start)

on server side

import time
from flask import Flask, request, jsonify
app = Flask(__name__)

@app.route('/test' ,methods=['POST'])
def predict():  
    start_pre = time.time()
    if request.method == 'POST':
        if 'file' not in request.files:
           return "someting went wrong"
           
    print('request files checking takes: ', time.time()-start_pre, flush=True)
    return jsonify({
        'result':'Get the results'
    })

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=5999, debug=True)

Thank you so much.

0 Answers
Related