gridflowai commited on
Commit
054bb10
Β·
1 Parent(s): 1913687

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +5 -5
  2. app.py +34 -0
  3. model.h5 +3 -0
  4. requirements.txt +6 -0
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Catvsdog
3
- emoji: πŸ¦€
4
- colorFrom: yellow
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.50.2
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
+ title: Blogfeedback Demo
3
+ emoji: πŸ“š
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 3.42.0
8
  app_file: app.py
9
  pinned: false
10
  ---
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 the pre-trained model
7
+ model = tf.keras.models.load_model('model.h5') # Replace with the path to your saved model
8
+
9
+ # Define a Gradio interface for image classification
10
+ def classify_image(image):
11
+ # Preprocess the input image
12
+ image = Image.fromarray(image)
13
+ image = image.resize((128, 128))
14
+ image = np.array(image)
15
+ image = image / 255.0 # Normalize the pixel values
16
+
17
+ # Make a prediction
18
+ prediction = model.predict(np.expand_dims(image, axis=0))
19
+
20
+ # Get the class label
21
+ class_label = "Dog" if prediction[0][0] < 0.5 else "Cat"
22
+
23
+ return class_label
24
+
25
+ # Create a Gradio interface
26
+ iface = gr.Interface(fn=classify_image,
27
+ inputs="image",
28
+ outputs="text",
29
+ capture_session=True)
30
+
31
+ # Launch the Gradio interface
32
+
33
+
34
+ iface.launch(server_name="0.0.0.0", server_port=7860)
model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae15813984fa0368d190eb52389ba701d7f91dee0cc2a22bf4899f59dce5facd
3
+ size 61441760
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ xgboost==1.7.6
2
+ gradio
3
+ scikit-learn==1.2.2
4
+ tensorflow==2.12.0
5
+ numpy
6
+