1234567891011121314151617181920212223242526272829303132 |
- package examples.utils;
- import com.alibaba.fastjson.JSONObject;
- import org.apache.commons.lang3.StringUtils;
- public class RosUtil {
- public static int multiClassLabel(JSONObject labelJson, String labelKey) {
- if (!labelJson.containsKey(labelKey) && StringUtils.isBlank(labelJson.getString(labelKey))) {
- return 0;
- }
- int labelValue = labelJson.getInteger(labelKey);
- if (labelValue <= 0) {
- return 0;
- } else if (labelValue == 1) {
- return 1;
- } else if (labelValue <= 4) {
- return 2;
- } else if (labelValue <= 8) {
- return 3;
- } else if (labelValue <= 14) {
- return 4;
- } else if (labelValue <= 21) {
- return 5;
- } else if (labelValue <= 50) {
- return 6;
- } else {
- return 7;
- }
- }
- }
|