SuperSecureHuman commited on
Commit
d8e4c27
1 Parent(s): 70f4ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -1,7 +1,15 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
3
 
4
- pipe = pipeline(task="image-classification", model="SuperSecureHuman/Flower-CNN")
 
 
 
 
 
 
 
5
 
6
  class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
7
 
@@ -9,10 +17,11 @@ image = gr.inputs.Image(shape=(300,300))
9
 
10
  label = gr.outputs.Label(num_top_classes=5)
11
 
12
- gr.Interface.from_pipeline(pipe,
13
  title="Flower Classification",
14
  description="Flower CNN",
15
  inputs = image,
16
  outputs = label,
17
  live=True,
 
18
  allow_flagging="never").launch()
 
1
  import gradio as gr
2
+ #from transformers import pipeline
3
+ from tensorflow.keras.models import load_model
4
 
5
+ #pipe = pipeline(task="image-classification", model="SuperSecureHuman/Flower-CNN")
6
+
7
+ model=load_model('./model.h5')
8
+
9
+ def predict_image(img):
10
+ img_4d = img.reshape(-1,300,300,3)
11
+ prediction = model.predict(img_4d)[0]
12
+ return {class_names[i]: float(prediction[i]) for i in range(5)}
13
 
14
  class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
15
 
 
17
 
18
  label = gr.outputs.Label(num_top_classes=5)
19
 
20
+ gr.Interface.from_pipeline(fn=predict_image,
21
  title="Flower Classification",
22
  description="Flower CNN",
23
  inputs = image,
24
  outputs = label,
25
  live=True,
26
+ interpretation='default',
27
  allow_flagging="never").launch()