cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
ray_play.py
Go to the documentation of this file.
1 import ray
2 from ray.util.queue import Queue
3 
4 import sys
5 import os
6 import numpy as np
7 import cv2 as cv
8 
9 ray.init(dashboard_port=50051, num_cpus=8)
10 
11 image_file=os.environ['cFpRootDir'] + "ROLE/vision/hls/harris/test/512x512.png"
12 frame = cv.imread(image_file, cv.IMREAD_COLOR)
13 
14 # You can pass this object around to different tasks/actors
15 queue = Queue(maxsize=100)
16 
17 @ray.remote
18 def consumer(i, queue, frame):
19  next_item = queue.get(block=True, timeout=100)
20  print(f"will work on {next_item} and then put in back in the queue")
21  for l in range(10000000):
22  k = i + l
23  frame_ret = cv.medianBlur(frame, 9)
24  queue.put(next_item)
25  return frame_ret
26 
27 
28 consumers = [consumer.remote(i, queue, frame) for i in range(5)]
29 
30 [queue.put(j) for j in ([["10.12.200.73" , "2718"],
31  ["10.12.200.24" , "2719"],
32  ["10.12.200.11" , "2720"],
33  ["10.12.200.19" , "2721"],
34  ["10.12.200.29" , "2722"]])]
35 
36 
37 results = ray.get(consumers)
38 print('Tasks executed')
39 
40 for t in range(len(results)):
41  file_out = "/tmp/img_"+str(t)+".png"
42  cv.imwrite(file_out, results[t])
def consumer(i, queue, frame)
Definition: ray_play.py:18