hwajjala commited on
Commit
29c69b2
β€’
1 Parent(s): edd1aeb

Update flagging arguments and add decision

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -69,8 +69,17 @@ def predict_fn(input_img):
69
  cosine_simlarities.reshape(1, -1)
70
  )
71
  logger.info(f"probabilities: {probabilities}")
 
 
 
 
 
 
 
 
 
72
  decision_json = json.dumps(
73
- {"is_base_body": float(probabilities[0][1].round(3))}
74
  ).encode("utf-8")
75
  logger.info(f"decision_json: {decision_json}")
76
  return decision_json
@@ -86,15 +95,14 @@ iface = gr.Interface(
86
  probability < 0.4, the image can be automatically REJECTED as NOT as base
87
  body. All other cases will be submitted for moderation.
88
 
89
- To minimize noise, please flag the input only if you think there is an error
90
- in the probability returned by the model and it is off by at least 0.2
91
  """,
92
 
93
  allow_flagging="manual",
94
  flagging_options=[
95
- "probability error > 0.5",
96
- "0.2 < probability error < 0.5",
97
- "probability error < 0.2"
98
  ],
99
  flagging_callback=hf_writer
100
  )
 
69
  cosine_simlarities.reshape(1, -1)
70
  )
71
  logger.info(f"probabilities: {probabilities}")
72
+ result_probabilty = float(probabilities[0][1].round(3))
73
+ # get decision string
74
+ if result_probabilty > 0.95:
75
+ decision = "AUTO ACCEPT"
76
+ elif result_probabilty < 0.4:
77
+ decision = "AUTO REJECT"
78
+ else:
79
+ decision = "MODERATION"
80
+ logger.info(f"decision: {decision}")
81
  decision_json = json.dumps(
82
+ {"is_base_body": result_probabilty, "decision": decision}
83
  ).encode("utf-8")
84
  logger.info(f"decision_json: {decision_json}")
85
  return decision_json
 
95
  probability < 0.4, the image can be automatically REJECTED as NOT as base
96
  body. All other cases will be submitted for moderation.
97
 
98
+ Please flag if you think the decision is wrong.
 
99
  """,
100
 
101
  allow_flagging="manual",
102
  flagging_options=[
103
+ ": decision hould be accept",
104
+ ": decision hould be reject",
105
+ ": decision hould be moderation"
106
  ],
107
  flagging_callback=hf_writer
108
  )