Objects Expression recognition
This notebooks shows some preliminary work on detecting objects expressions with cvlib. It is mainly meant to explore its capabilities and to decide on future research directions. We package our code into a ammico package that is imported here:
[1]:
import ammico
from ammico import utils as mutils
from ammico import display as mdisplay
import ammico.objects as ob
Set an image path as input file path.
[2]:
images = mutils.find_files(
path="data/",
limit=10,
)
[3]:
mydict = mutils.initialize_dict(images)
Manually inspect what was detected
To check the analysis, you can inspect the analyzed elements here. Loading the results takes a moment, so please be patient. If you are sure of what you are doing.
[4]:
mdisplay.explore_analysis(mydict, identify="objects")
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 mdisplay.explore_analysis(mydict, identify="objects")
AttributeError: module 'ammico.display' has no attribute 'explore_analysis'
Detect objects and directly write to csv
[5]:
for key in mydict:
mydict[key] = ob.ObjectDetector(mydict[key]).analyse_image()
0% | |
Downloading yolov4.cfg from https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4.cfg
Downloading yolov4.weights from https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights
99% |####################################################################### |
Downloading yolov3_classes.txt from https://github.com/arunponnusamy/object-detection-opencv/raw/master/yolov3.txt
100% | |
Convert the dictionary of dictionarys into a dictionary with lists:
[6]:
outdict = mutils.append_data_to_dict(mydict)
df = mutils.dump_df(outdict)
Check the dataframe:
[7]:
df.head(10)
[7]:
| filename | person | bicycle | car | motorcycle | airplane | bus | train | truck | boat | traffic light | cell phone | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | data/102730_eng.png | yes | no | no | no | no | no | no | yes | no | no | no |
| 1 | data/102141_2_eng.png | yes | no | no | no | no | no | no | no | no | no | no |
| 2 | data/106349S_por.png | yes | no | no | no | no | no | no | no | no | no | yes |
Write the csv file:
[8]:
df.to_csv("./data_out.csv")
[ ]: