I have a trained model which is loading in the main python file. It is working and giving predictions when I choose kivy's FileChooseListView but I wanted to make it better so I used plyer filechooser which did load images but the problem is now my model is not loading. Its not giving any error either. Can anyone tell what the problem is?
I have tried correcting it and debugging but nothing is happening.
main.py
class UploadScreen(Screen):
def file_chooser(self):
filechooser.open_file(on_selection=self.selected)
def selected(self, filename):
try:
self.ids.my_image.source = filename[0]
print(filename[0])
CATEGORIES = ['Diving Side', # 1.
'Golf-Swing-Front', # 2.
'Golf-Swing-Side', # 3.
'Kicking-Front', # 4.
'Kicking-Side', # 5.
'Lifting', # 6
'Riding-Horse', # 7
'Run-Side', # 8.
'SkateBoarding-Front', # 9
'Swing-Bench', # 10.
'Swing-SideAngle', # 11
'Walk-Front' # 12.
]
model = tf.keras.models.load_model("./model/model") /// Model is not loading
size = (90, 90)
img_array = cv2.imread(filename[0])
pd_array = []
im = cv2.resize(img_array, size, cv2.INTER_AREA)
im = im.astype('float32')
pd_array.append(im)
np_image = np.array(pd_array)
print("NP array ")
print(np_image.shape)
predictions = model.predict(np_image)
top = np.argmax(predictions)
print(predictions)
# top=top-1
print(top)
print("prediction is "+CATEGORIES[top])
results = CATEGORIES[top]
print(results)
name = results
# Update the label
self.ids.name_label.text = name
print("Captured")
except:
pass
.kv
<UploadScreen>:
name: 'upload'
id: upload
orientation: 'vertical'
canvas:
Color:
# rgba: 0.439,0.501,0.564,1
rgb: 0.662, 0.662, 0.662, 1
Rectangle:
size: self.size
pos: self.pos
MDGridLayout:
rows:5
cols:1
spacing: 25
padding: 25
MDLabel:
id: name_label
text: "Results"
bold: True
font_size: 35
color: 0.137, 0.156, 0.419, 1
halign: 'center'
size_hint_y: None
height: self.texture_size[1]
MDRaisedButton:
text: 'Select Image'
font_size: 18
size_hint: None, None
width: root.width*1
height: root.height*0.1
md_bg_color: 0.258, 0.372, 0.921, 1
text_color: 1,1,1,1
pos_hint: {'center_x':0.5,'center_y':0.3}
on_press: root.file_chooser()
BoxLayout:
orientation: "vertical"
size: root.width, root.height
padding: 50
spacing: 20
Image:
id: my_image
source: ""
MDRaisedButton:
text: 'Back'
font_size: 18
size_hint: None, None
width: root.width*1
height: root.height*0.1
md_bg_color: 0.258, 0.372, 0.921, 1
text_color: 1,1,1,1
pos_hint: {'center_x':0.5,'center_y':0.3}
on_press: root.manager.current = 'main'