Feature Request: Impulse Specific Expert Code Snipets

@jenny @louis @shawn_edgeimpulse (My go-to group :smiley:)

As I train more students to write Arduino code using Edgeimpulse models, it becomes more evident that the biggest bottle neck in their machine learning development is the translation from classification results to useable code.

I also lack in this area and often relie on the expertise of @janjongboom @rjames (and others) for code snippets to solve specific problems. I was wondering if anyone would be supportive of a Github Repository or area in the Docs that has code snippets to help intermedicate coders organized by: sound, motion, vision-classify, vision-fomo, other?

Example: Moving from classfiying models to FOMO I needed a count of each label that occured, but the old classifiy method which gave a count of all labels found EI_CLASSIFIER_LABEL_COUNT worked differently in FOMO as it gives you the total number of objects found not the total number of label types found. When I described the issue Jan sent this code which immediately solved my problem.



 #include <map>

///////////////////



     std::map<std::string, int> cnt;
     for (size_t ix = 0; ix < EI_CLASSIFIER_OBJECT_DETECTION_COUNT; ix++) {
         auto bb = result.bounding_boxes[ix];
         if (bb.value == 0) {
             continue;
         }
 
         std::string label(bb.label);
         auto cnt_entry = cnt.find(label);
         if (cnt_entry == cnt.end()) {
             cnt[label] = 1;
         }
         else {
             cnt_entry->second++;
         }
 
         printf("%s (%f) [ x: %u, y: %u, width: %u, height: %u ]\n", bb.label, bb.value, bb.x, bb.y, bb.width, bb.height);
     }

.

The above code also had enough of the normal code for me to figure out how to use it.
.

Recently when working with a student on a sound model, the classified data did not smoothly convert to the string and integer varaibles she was expecting. I had to help her use a char array. Another time using FOMO a student put an unsigned variable into an integer. It should have been fine but for some reason it needed (int) to convert the value

int myVar = (int)eiUnsignedVar;

Coding at the intermediate level is always hard, any chance we can have a few code snippets for specific area gotchas!

If a solution was on an EdgeImpulse Github I would submit some of the issues and solutions I have found, (code snippet, working code and zipped model). A code snippet location might allow some advanced private code for specific paid projects to be shared without giving details about the private project.

Amazing wht kids are able to do using Edgeimpulse models. It is a dream come true to be able to teach this successfully.

Jeremy Ellis

Hey Jeremy,

Though it’s not expert code snippets, I am keen to include more expert mode snippets :slight_smile:

In particularly I’ve just added some of the FAQ expert mode tips for FOMO in the docs here

Any feedback welcome and I definitely intend to release FOMOv2 with a lot more expert mode hooks from day 1

Cheers, Mat

3 Likes

Those are great! :100: Yes give us more of these insider tips! I will definitely play with object_weight=100 and cut_point in expert mode.

model = train(num_classes=classes,
              learning_rate=0.0085,
              num_epochs=500,
              alpha=0.35,
              object_weight=100,
              train_dataset=train_dataset,
              validation_dataset=validation_dataset,
              best_model_path=BEST_MODEL_PATH,
              input_shape=MODEL_INPUT_SHAPE)

    cut_point = mobile_net_v2.get_layer('block_6_expand_relu')