cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_median_blur_images_ray Namespace Reference

Functions

def consumer (accel_mode, fpgas_queue, frames, i, debug_level=debug_level)
 
def mega_work (accel_mode, fpgas_queue, frames, debug_level, start, end)
 
def flatten (input)
 

Variables

bool accel_mode = False
 
 debug_level = logging.DEBUG
 
 stream
 
 stdout
 
 level
 
int width = 3840
 
int height = 2160
 
int total_size = height * width
 
int DATASET_SIZE = 50
 
int split = 1
 
int REPEATS = 1
 
 address
 
 fpgas_queue = Queue(maxsize=100)
 
 tic_capture = time.perf_counter()
 
list frames = []
 
list frames_ret = []
 
 frame = cv.imread(cv.samples.findFile("CARLA.jpg"))
 
 toc_capture = time.perf_counter()
 
list elapsed_times = []
 
 start_time = time.time()
 
 tic_consumers = time.perf_counter()
 
 frames_id = ray.put(frames)
 
 fpgas_queue_id = ray.put(fpgas_queue)
 
list consumers = [mega_work.remote(accel_mode, fpgas_queue_id, frames_id, debug_level, i*split, (i+1)*split) for i in range(int(len(frames)/split))]
 
 toc_consumers = time.perf_counter()
 
 tic_exec = time.perf_counter()
 
 results = ray.get(consumers)
 
 toc_exec = time.perf_counter()
 
 end_time = time.time()
 
 tic_save = time.perf_counter()
 
string image_name = "CARLA_out_"+str(t)+".jpg"
 
 toc_save = time.perf_counter()
 
int average_elapsed_time = sum(elapsed_times) / REPEATS
 

Function Documentation

◆ consumer()

def test_median_blur_images_ray.consumer (   accel_mode,
  fpgas_queue,
  frames,
  i,
  debug_level = debug_level 
)

Definition at line 70 of file test_median_blur_images_ray.py.

70 def consumer(accel_mode, fpgas_queue, frames, i, debug_level=debug_level):
71  logging.basicConfig(stream=sys.stdout, level=debug_level)
72 
73  frame = frames[i]
74  if accel_mode:
75  next_item = fpgas_queue.get(block=True, timeout=100)
76  logging.debug(f"will work on {next_item} and then put in back in the fpgas_queue")
77  # Flattening the image from 2D to 1D
78  image = frame.flatten()
79  output_array = trieres.vision.median_blur(image, total_size, next_item[0], int(next_item[1]), debug_level=debug_level)
80  frame = np.reshape(output_array, (height, width))
81  #frame = cv.medianBlur(frame, 9)
82  fpgas_queue.put(next_item)
83  logging.debug(f"finished working on {next_item} Now it is back in the fpgas_queue")
84  else:
85  logging.debug(f"Apllying medianBlur")
86  frame = cv.medianBlur(frame, 9)
87  return frame
88 
89 
90 @ray.remote
def consumer(accel_mode, fpgas_queue, frames, i, debug_level=debug_level)
Here is the caller graph for this function:

◆ flatten()

def test_median_blur_images_ray.flatten (   input)

Definition at line 95 of file test_median_blur_images_ray.py.

95 def flatten(input):
96  if(type(input[0])==list):
97  new_list = []
98  for i in input:
99  for j in i:
100  new_list.append(j)
101  return new_list
102  else:
103  return input
104 
105 try:
106  fn = sys.argv[1]
107 except:
108  fn = 0
109 

◆ mega_work()

def test_median_blur_images_ray.mega_work (   accel_mode,
  fpgas_queue,
  frames,
  debug_level,
  start,
  end 
)

Definition at line 91 of file test_median_blur_images_ray.py.

91 def mega_work(accel_mode, fpgas_queue, frames, debug_level, start, end):
92  print("will work on ["+str(start)+"-"+str(end)+"]")
93  return [consumer(accel_mode, fpgas_queue, frames, x, debug_level=debug_level) for x in range(start, end)]
94 
def mega_work(accel_mode, fpgas_queue, frames, debug_level, start, end)
Here is the call graph for this function:

Variable Documentation

◆ accel_mode

bool test_median_blur_images_ray.accel_mode = False

Definition at line 45 of file test_median_blur_images_ray.py.

◆ address

test_median_blur_images_ray.address

Definition at line 59 of file test_median_blur_images_ray.py.

◆ average_elapsed_time

int test_median_blur_images_ray.average_elapsed_time = sum(elapsed_times) / REPEATS

Definition at line 183 of file test_median_blur_images_ray.py.

◆ consumers

list test_median_blur_images_ray.consumers = [mega_work.remote(accel_mode, fpgas_queue_id, frames_id, debug_level, i*split, (i+1)*split) for i in range(int(len(frames)/split))]

Definition at line 134 of file test_median_blur_images_ray.py.

◆ DATASET_SIZE

int test_median_blur_images_ray.DATASET_SIZE = 50

Definition at line 53 of file test_median_blur_images_ray.py.

◆ debug_level

test_median_blur_images_ray.debug_level = logging.DEBUG

Definition at line 46 of file test_median_blur_images_ray.py.

◆ elapsed_times

test_median_blur_images_ray.elapsed_times = []

Definition at line 125 of file test_median_blur_images_ray.py.

◆ end_time

test_median_blur_images_ray.end_time = time.time()

Definition at line 171 of file test_median_blur_images_ray.py.

◆ fpgas_queue

test_median_blur_images_ray.fpgas_queue = Queue(maxsize=100)

Definition at line 67 of file test_median_blur_images_ray.py.

◆ fpgas_queue_id

test_median_blur_images_ray.fpgas_queue_id = ray.put(fpgas_queue)

Definition at line 131 of file test_median_blur_images_ray.py.

◆ frame

test_median_blur_images_ray.frame = cv.imread(cv.samples.findFile("CARLA.jpg"))

Definition at line 114 of file test_median_blur_images_ray.py.

◆ frames

list test_median_blur_images_ray.frames = []

Definition at line 112 of file test_median_blur_images_ray.py.

◆ frames_id

test_median_blur_images_ray.frames_id = ray.put(frames)

Definition at line 130 of file test_median_blur_images_ray.py.

◆ frames_ret

list test_median_blur_images_ray.frames_ret = []

Definition at line 113 of file test_median_blur_images_ray.py.

◆ height

int test_median_blur_images_ray.height = 2160

Definition at line 50 of file test_median_blur_images_ray.py.

◆ image_name

string test_median_blur_images_ray.image_name = "CARLA_out_"+str(t)+".jpg"

Definition at line 176 of file test_median_blur_images_ray.py.

◆ level

test_median_blur_images_ray.level

Definition at line 47 of file test_median_blur_images_ray.py.

◆ REPEATS

int test_median_blur_images_ray.REPEATS = 1

Definition at line 55 of file test_median_blur_images_ray.py.

◆ results

def test_median_blur_images_ray.results = ray.get(consumers)

Definition at line 161 of file test_median_blur_images_ray.py.

◆ split

int test_median_blur_images_ray.split = 1

Definition at line 54 of file test_median_blur_images_ray.py.

◆ start_time

test_median_blur_images_ray.start_time = time.time()

Definition at line 127 of file test_median_blur_images_ray.py.

◆ stdout

test_median_blur_images_ray.stdout

Definition at line 47 of file test_median_blur_images_ray.py.

◆ stream

test_median_blur_images_ray.stream

Definition at line 47 of file test_median_blur_images_ray.py.

◆ tic_capture

test_median_blur_images_ray.tic_capture = time.perf_counter()

Definition at line 110 of file test_median_blur_images_ray.py.

◆ tic_consumers

test_median_blur_images_ray.tic_consumers = time.perf_counter()

Definition at line 129 of file test_median_blur_images_ray.py.

◆ tic_exec

test_median_blur_images_ray.tic_exec = time.perf_counter()

Definition at line 159 of file test_median_blur_images_ray.py.

◆ tic_save

test_median_blur_images_ray.tic_save = time.perf_counter()

Definition at line 174 of file test_median_blur_images_ray.py.

◆ toc_capture

test_median_blur_images_ray.toc_capture = time.perf_counter()

Definition at line 123 of file test_median_blur_images_ray.py.

◆ toc_consumers

test_median_blur_images_ray.toc_consumers = time.perf_counter()

Definition at line 157 of file test_median_blur_images_ray.py.

◆ toc_exec

test_median_blur_images_ray.toc_exec = time.perf_counter()

Definition at line 164 of file test_median_blur_images_ray.py.

◆ toc_save

test_median_blur_images_ray.toc_save = time.perf_counter()

Definition at line 179 of file test_median_blur_images_ray.py.

◆ total_size

int test_median_blur_images_ray.total_size = height * width

Definition at line 51 of file test_median_blur_images_ray.py.

◆ width

int test_median_blur_images_ray.width = 3840

Definition at line 49 of file test_median_blur_images_ray.py.