Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
30 |
-
|
31 |
-
|
|
|
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()
|