heinini2 commited on
Commit
9225ecd
1 Parent(s): 64f33d3

Upload 3 files

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