Eric2mangel commited on
Commit
85a57d9
·
verified ·
1 Parent(s): 8cbe18f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+
6
+ # Charger ton modèle
7
+ model = tf.keras.models.load_model("mon_modele.h5")
8
+
9
+ # Classes
10
+ classes = ["Cubisme", "Expressionnisme", "Post-impressionnisme"]
11
+
12
+ # Fonction de prédiction
13
+ def predire(image):
14
+ image = tf.image.resize(image, (224, 224)) / 255.0
15
+ preds = model.predict(tf.expand_dims(image, axis=0))[0]
16
+ confidences = {classes[i]: float(preds[i]) for i in range(len(classes))}
17
+ return confidences
18
+
19
+ # Interface Gradio
20
+ demo = gr.Interface(
21
+ fn=predire,
22
+ inputs=gr.Image(type="numpy", label="Importer une œuvre"),
23
+ outputs=gr.Label(num_top_classes=3, label="Probabilités par mouvement pictural"),
24
+ title="🎨 Classification de style pictural",
25
+ description="Upload une image et découvre le mouvement pictural estimé par le CNN."
26
+ )
27
+
28
+ demo.launch()