rinitsar commited on
Commit
3985f4e
1 Parent(s): 8270ae1

Upload 5 files

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. app.py +34 -0
  3. dratini.png +0 -0
  4. eevee.jpg +0 -0
  5. jigglypuff.jpg +0 -0
  6. pokemon_classifier_model.keras +3 -0
.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
+ pokemon_classifier_model.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ # Load your custom regression model
7
+ model_path = "pokemon_classifier_model.keras"
8
+ model = tf.keras.models.load_model(model_path)
9
+
10
+ labels = ['Dratini', 'Eevee', 'Jigglypuff']
11
+
12
+ # Define regression function
13
+ def predict_regression(image):
14
+ # Preprocess image
15
+ image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
16
+ image = image.resize((150, 150)).convert('RGB') #resize the image to 28x28 and converts it to gray scale
17
+ image = np.array(image)
18
+ print(image.shape)
19
+ # Predict
20
+ prediction = model.predict(image[None, ...]) # Assuming single regression value
21
+ confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))}
22
+ return confidences
23
+
24
+ # Create Gradio interface
25
+ input_image = gr.Image()
26
+ output_text = gr.Textbox(label="Predicted Value")
27
+ interface = gr.Interface(
28
+ fn=predict_regression,
29
+ inputs=input_image,
30
+ outputs=gr.Label(),
31
+ examples=["dratini.png", "eevee.jpg", "jigglypuff.jpg"],
32
+ description="A simple mlp classification model for image classification using the pokemon dataset."
33
+ )
34
+ interface.launch()
dratini.png ADDED
eevee.jpg ADDED
jigglypuff.jpg ADDED
pokemon_classifier_model.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f04661b4c00ee6fb9591ab3244619f3d33dd7932c647d391d0c69d878f3e3f5
3
+ size 250560147