Skip to content

Instantly share code, notes, and snippets.

@juntao
Created February 24, 2021 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juntao/b00aaf96bd3827c0b3e8f6942f28fdc9 to your computer and use it in GitHub Desktop.
Save juntao/b00aaf96bd3827c0b3e8f6942f28fdc9 to your computer and use it in GitHub Desktop.
let labels = include_str!("aiy_food_V1_labelmap.txt");
let mut i = 0;
let mut max_index: i32 = -1;
let mut max_value: u8 = 0;
while i < res_vec.len() {
let cur = res_vec[i];
if cur > max_value {
max_value = cur;
max_index = i as i32;
}
i += 1;
}
let mut label_lines = labels.lines();
for _i in 0..max_index {
label_lines.next();
}
let class_name = label_lines.next().unwrap().to_string();
if max_value > 50 && max_index != 0 {
println!("The image {} contains a <a href='https://www.google.com/search?q={}'>{}</a>", confidence.to_string(), class_name, class_name);
} else {
println!("No food item is detected");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment