ZELEFACK commited on
Commit
6e85977
1 Parent(s): 15d3e11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -19
app.py CHANGED
@@ -1,27 +1,33 @@
1
  import gradio as gr
2
  import tensorflow as tf
3
- model_0 = tf.keras.models.load_model('bestmodel_porno_final_meilleure100%2.0.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
- label = gr.outputs.Label(num_top_classes=3)
24
 
25
  gr.Interface(
26
- fn=classify_image, inputs=image, outputs=label, interpretation="default"
 
 
 
 
 
 
 
27
  ).launch()
 
1
  import gradio as gr
2
  import tensorflow as tf
3
+ import numpy as np
4
+ import cv2
5
+
6
+ new_model = tf.keras.models.load_model('best_model_mammography.h5')
7
+
8
+ def classify_image(file_name):
9
+ img1 = cv2.imread(file_name.name.replace("\\",'/'),0)
10
+ img = cv2.resize(img1, (224,224))
11
+ img = img.reshape(img.shape[0],img.shape[1],1)
12
+ pred = new_model.predict(np.array([img]))
13
+ pred = np.round(pred,1)
14
+ if pred == 0:
15
+ pred = "Vôtre cancer est Begnine"
 
16
  else:
17
+ pred= "Vôtre cancer est maline"
18
+ return pred
19
 
20
 
21
+ image = gr.inputs.File( file_count="single",type="file", label="Fichier à Traiter (sous fichier .pgm)")
22
+ # label = gr.outputs.Label(num_top_classes=3)
23
 
24
  gr.Interface(
25
+ fn=classify_image,
26
+ inputs=image,
27
+ outputs="text",
28
+ interpretation="default",
29
+ live=True,
30
+ theme="dark-peach",
31
+ title="API BREASTNET de Test de diagnostique du Cancer de Sein",
32
+ description="Cette API est utilisé pour dire si le Cancer de sein est Maline ou Pas"
33
  ).launch()