ZELEFACK commited on
Commit
7689af3
1 Parent(s): d6f4805

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -26
app.py CHANGED
@@ -1,26 +1,26 @@
1
- import gradio as gr
2
- import tensorflow as tf
3
- model_0 = tf.keras.models.load_model('bestmodel.h5')
4
- def classify_image(inp):
5
- inp = inp.reshape((-1, 224, 224, 3))
6
- prediction = model_0.predict(inp)
7
- if prediction.argmax() == 0:
8
- output = "Rifle violence"
9
- elif prediction.argmax() == 1:
10
- output = "guns violence"
11
- elif prediction.argmax() == 2:
12
- output = "knife violence"
13
- elif prediction.argmax() == 3:
14
- output = "image porno"
15
- elif prediction.argmax() == 4:
16
- output = "personne habillée"
17
- else:
18
- output = "tank violence"
19
- return output
20
-
21
-
22
- image = gr.inputs.Image(shape=(224, 224))
23
-
24
- gr.Interface(
25
- fn=classify_image, inputs=image, outputs="text"
26
- ).launch()
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ model_0 = tf.keras.models.load_model('bestmodel.h5')
4
+ def classify_image(inp):
5
+ inp = inp.reshape((-1, 224, 224, 3))
6
+ prediction = model_0.predict(inp)
7
+ if prediction.argmax() == 0:
8
+ output = "Rifle violence"
9
+ elif prediction.argmax() == 1:
10
+ output = "guns violence"
11
+ elif prediction.argmax() == 2:
12
+ output = "knife violence"
13
+ elif prediction.argmax() == 3:
14
+ output = "image porno"
15
+ elif prediction.argmax() == 4:
16
+ output = "personne habillée"
17
+ else:
18
+ output = "tank violence"
19
+ return output
20
+
21
+
22
+ image = gr.inputs.Image(shape=(224, 224))
23
+
24
+ gr.Interface(
25
+ fn=classify_image, inputs=image, outputs="text",live=True, theme="dark-peach",title="API de détection des images violentes",
26
+ ).launch()