Here will introduce a process to obtain an original image before inferencing and then send it to Edge Impulse studio to increase data for next retraining. Moreover it also collect inference results and reserve them in DeviceOn for further analysis later.
- Click
System
in theSettings
menu on the left. - In the upper right options, click
System Settings
and then selectDevic File Synchonization
from the drop-down menu ofItem
. - The default value of
Sync Interval(minute)
is10
minutes as a period for synchronous uploading.
NOTE: If you do not see the above menu, please contact your
Device
administrators to modify your account access permission.
- Next click
List
in theDevice
menu on the left. - Click the
MORE
icon on the right side of the deviceair020
.
- Check if 'Devic File Synchonization' is enabled and then click
Confirm
to complete the setup.
- Back to the edge device (AIR-020), let's create directories for saving captured images and inference results.
cd /opt/linux-sdk-python/examples/image
sudo mkdir Original_Image
sudo mkdir Inference_results
- Then specify the upload synchronization directory on the edge device (AIR-020) by editing the
FileSync.ini
file.
sudo gedit /usr/local/AgentService/FileSync.ini
- In the
FileSync.ini
file, changeDir=XXX...
to the specifiedDir=/opt/linux-sdk-python/examples/image/Inference_results
. - Then click
Save
to save and close theFileSync.ini
file.
- After restarting the AIR-020 and the inference app will be launched automatically as well.
- Go to the
DeviceOn
server web UI, clickList
inDevice
on the left menu. - Click the
MORE
icon on the right side ofair020
. - Check whether its
Local Path:
ofDevice File Synchronization
is/opt/linux-sdk-python/examples/image/Inference_results
.
- In this repo, the DEMO app will save a captured image and its inference result into respective directories in AIR-020 per five seconds.
- After starting the inference app for ten minutes, go to the DeviceOn server web UI and then click its left menu
Event Log
to be able to find the data transferring information.
- In addition, captured images in the
Original_Image
directory can be uploaded to theEdge Impulse
platform according to the section of OPS | Collect data for model retraining.
- For example, modify the default vaule of
5
in/opt/linux-sdk-python/examples/image/classify.py
, as shown in the column 203 therein. 5
means to save data per five seconds. If it's changed to6
, it will save data per six seconds correspondingly.
if (seconds % 5) == 0 and (seconds > sec_list1) :
- To stop saving data at AIR-020, use the symbol
"""
to igore the following codes from the column203
to230
.
"""
if (seconds % 5) == 0 and (seconds > sec_list1) :
#seconds.tm_sec = seconds.tm_sec + 1
#if n == 1:
###
local_time = time.localtime()
timeString = time.strftime("%Y_%m_%d_%H_%M_", local_time)
###
i = i + 1
print ('img.shape2', original_image.shape)
#original_img_pad = "./Original_image/" + str(timeString) + str(i)+".jpg"
#cv2.imwrite(original_img_pad, original_image)
img_pad = "/opt/linux-sdk-python/examples/image/Inference_results/" + str(timeString) + str(i)+".jpg"
cv2.imwrite(img_pad, cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
timestamp = str(timeString) + str(i)
data_list_1.insert(0, timestamp)
with open('/opt/linux-sdk-python/examples/image/Inference_results/Inference_results.csv', 'a') as file:
#writer = csv.writer(file,delimiter=';')
writer = csv.writer(file)
#for item in str(data_list_1):
# writer.writerows(item)
writer.writerow((data_list_1))
seconds_1 = int(seconds_threshold) + 1
sec_list.append(seconds_1)
"""
- For example, modify the default vaule of
5
in/opt/linux-sdk-python/edge_impulse_linux/image.py
, as shown in the column 75 therein. 5
means to save a image per five seconds. If it's changed to6
, it will save data per six seconds correspondingly.
if (seconds % 5) == 0:
- To stop saving images at AIR-020, use the symbol
"""
to igore the following codes from the column75
to88
.
"""
if (seconds % 5) == 0:
local_time = time.localtime()
timeString = time.strftime("%Y_%m_%d_%H_%M_%S_", local_time)
img_test = img
i = 1
img_pad = "Original_image/"+str(timeString) +".jpg"
if os.path.isfile(img_pad) == True:
#cv2.imwrite("Original_image/"+timeString+"NG.jpg",img_test)
print #("YA" )
else:
#print ("NO YA")
cv2.imwrite(img_pad, img_test)
i = i + 1
"""