stevafil commited on
Commit
242147e
1 Parent(s): 47276d2

Upload 46 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model_2_familyguy.keras filter=lfs diff=lfs merge=lfs -text
app_model2.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ # Load the model
7
+ model_path = "model_2_familyguy.keras"
8
+ model = tf.keras.models.load_model(model_path)
9
+
10
+ # Define the core prediction function
11
+ def predict_familyguy(image):
12
+ # Preprocess image
13
+ image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
14
+ image = image.resize((150, 150)) # Resize the image to 150x150
15
+ image = np.array(image) / 255.0 # Normalize the image
16
+ image = np.expand_dims(image, axis=0) # Add batch dimension
17
+
18
+ # Predict
19
+ prediction = model.predict(image)
20
+
21
+ # Convert the probabilities to rounded values
22
+ prediction = np.round(prediction, 2)
23
+
24
+ # Separate the probabilities for each class
25
+ p_brian = prediction[0][0] # Probability for class 'Brain Griffin'
26
+ p_lois = prediction[0][1] # Probability for class 'Lois Griffin'
27
+ p_peter = prediction[0][2] # Probability for class 'Peter Griffin'
28
+ p_stewie = prediction[0][3] # Probability for class 'Stewie Griffin'
29
+
30
+ return {'brian': p_brian, 'lois': p_lois, 'peter': p_peter, 'stewie': p_stewie}
31
+
32
+ # Create the Gradio interface
33
+ input_image = gr.Image()
34
+ iface = gr.Interface(
35
+ fn=predict_familyguy,
36
+ inputs=input_image,
37
+ outputs=gr.Label(num_top_classes=4), # This will display the top 4 class labels
38
+ examples=["images/Brain1.png", "images/Brain2.jpg", "images/Brain3.jpg",
39
+ "images/Lois1.png", "images/Lois2.png", "images/Lois3.png",
40
+ "images/Peter1.jpg", "images/Peter2.jpg", "images/Peter3.jpg",
41
+ "images/Stewie1.jpg", "images/Stewie2.jpg", "images/Stewie3.jpg"],
42
+ description="Upload an image to classify it as Brian, Lois, Peter, or Stewie."
43
+ )
44
+
45
+ iface.launch()
images/Brain1.png ADDED
images/Brain10.jpg ADDED
images/Brain11.jpg ADDED
images/Brain2.jpg ADDED
images/Brain3.jpg ADDED
images/Brain4.jpg ADDED
images/Brain5.jpg ADDED
images/Brain6.jpg ADDED
images/Brain7.jpg ADDED
images/Brain8.jpg ADDED
images/Brain9.jpg ADDED
images/Lois1.png ADDED
images/Lois10.png ADDED
images/Lois2.png ADDED
images/Lois3.png ADDED
images/Lois4.png ADDED
images/Lois5.png ADDED
images/Lois6.png ADDED
images/Lois7.png ADDED
images/Lois8.png ADDED
images/Lois9.png ADDED
images/Peter1.jpg ADDED
images/Peter10.jpg ADDED
images/Peter2.jpg ADDED
images/Peter3.jpg ADDED
images/Peter4.jpg ADDED
images/Peter5.jpg ADDED
images/Peter6.jpg ADDED
images/Peter7.jpg ADDED
images/Peter8.jpg ADDED
images/Peter9.jpg ADDED
images/Stewie1.jpg ADDED
images/Stewie10.jpg ADDED
images/Stewie11.jpg ADDED
images/Stewie12.jpg ADDED
images/Stewie2.jpg ADDED
images/Stewie3.jpg ADDED
images/Stewie4.jpg ADDED
images/Stewie5.jpg ADDED
images/Stewie6.jpg ADDED
images/Stewie7.jpg ADDED
images/Stewie8.jpg ADDED
images/Stewie9.jpg ADDED
model_2_familyguy.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1634cd8ec9394c531b80f037f5247af92998f0b800d70f76157d80d5fc874fc
3
+ size 41542895
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tensorflow==2.15.0