vuchl001 commited on
Commit
c407862
1 Parent(s): 56c60a4

Upload 2 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
+ pokemon_model_transferlearning.keras filter=lfs diff=lfs merge=lfs -text
app (1).py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = "trainpokemon_model_transferlearning.weights.h5"
8
+ model_path = "pokemon_model_transferlearning.keras"
9
+
10
+ #model.load_weights(model_path)
11
+ model = tf.keras.models.load_model(model_path)
12
+
13
+ labels = ['Ditto','Venomoth','Venusaur']
14
+
15
+ # Define regression function
16
+ def predict_regression(image):
17
+ # Preprocess image
18
+ image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
19
+ image = image.resize((150, 150))#.convert('L') #resize the image to 28x28 and converts it to gray scale
20
+ image = np.array(image)
21
+ print(image.shape)
22
+ # Predict
23
+ prediction = model.predict(image[None, ...]) # Assuming single regression value
24
+ confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))}
25
+ return confidences
26
+
27
+ # Create Gradio interface
28
+ input_image = gr.Image()
29
+ output_text = gr.Textbox(label="Predicted Pokemon")
30
+ interface = gr.Interface(fn=predict_regression,
31
+ inputs=input_image,
32
+ outputs=gr.Label(),
33
+ examples=["pokemons/train/Ditto/00000008.jpg", "images/Venomoth.jpeg", "images/Venusaur.jpeg"],
34
+ description="A simple mlp classification model for image classification using the mnist dataset.")
35
+ interface.launch()
pokemon_model_transferlearning.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f01542752e51740cd8ba7704ce7ac23c397469183a6eaaa2c982d132c3cb828
3
+ size 250560147