Created
February 24, 2021 17:18
-
-
Save juntao/b00aaf96bd3827c0b3e8f6942f28fdc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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