mayhug commited on
Commit
5ce6afd
1 Parent(s): 4d4aa91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -11,7 +11,6 @@ in_tensor, *_ = inter.get_input_details()
11
  out_tensor, *_ = inter.get_output_details()
12
 
13
 
14
- @tf.function
15
  def process_data(content):
16
  img = tf.io.decode_jpeg(content, channels=3)
17
  img = tf.image.resize_with_pad(img, SIZE, SIZE, method="nearest")
@@ -26,13 +25,14 @@ def main(file: IO[bytes]):
26
  inter.set_tensor(in_tensor["index"], data)
27
  inter.invoke()
28
  result, *_ = inter.get_tensor(out_tensor["index"])
29
- *_, confidence = result
30
- print(f"Output confidence: {confidence:.3%}")
31
- return confidence
 
32
 
33
 
34
  image = inputs.Image(type="file")
35
- label = outputs.Label()
36
 
37
  interface = Interface(main, image, label)
38
  interface.launch()
 
11
  out_tensor, *_ = inter.get_output_details()
12
 
13
 
 
14
  def process_data(content):
15
  img = tf.io.decode_jpeg(content, channels=3)
16
  img = tf.image.resize_with_pad(img, SIZE, SIZE, method="nearest")
 
25
  inter.set_tensor(in_tensor["index"], data)
26
  inter.invoke()
27
  result, *_ = inter.get_tensor(out_tensor["index"])
28
+ safe, questionable, explicit = map(float, result)
29
+ possibilities = {"safe": safe, "questionable": questionable, "explicit": explicit}
30
+ print("Predict result:", possibilities)
31
+ return possibilities
32
 
33
 
34
  image = inputs.Image(type="file")
35
+ label = outputs.Label(type="confidences")
36
 
37
  interface = Interface(main, image, label)
38
  interface.launch()