Anas090 commited on
Commit
8b14104
·
verified ·
1 Parent(s): 6df4fde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -6,31 +6,26 @@ import numpy as np
6
  onnx_model_vgg19_path = "./vgg19-30epochs.onnx"
7
  onnx_model_inceptionv3_path = "./InceptionV3-20epochs.onnx"
8
  onnx_model_resnet101_path = "./Resnet101-30epochs.onnx"
9
- onnx_model_vgg16_path = "./vgg16.onnx"
10
 
11
 
12
 
13
- class_labels = ['Ajloun Castle', 'Hadrians Arch', 'Petra-siq', 'Roman Ruins-Jerash', 'Roman amphitheater', 'The Cardo Maximus of Jerash', 'Wadi Rum', 'petra-Treasury', 'umm qais']
14
- class_labels2 = ['Ajloun Castle', 'Hadrians Arch', 'Petra-siq', 'petra-Treasury', 'Roman amphitheater', 'Roman Ruins-Jerash', 'The Cardo Maximus of Jerash', 'umm qais', 'Wadi Rum']
15
 
16
  def predict_image(image_path, model):
17
 
18
  if model == "InceptionV3":
19
  img_size = (550, 475)
20
- labels = class_labels
21
  model_inceptionv3 = onnxruntime.InferenceSession(onnx_model_inceptionv3_path)
22
  elif model == "Resnet101":
23
  img_size = (250, 200)
24
- labels = class_labels
25
  model_resnet101 = onnxruntime.InferenceSession(onnx_model_resnet101_path)
26
  elif model == "Vgg19":
27
  img_size = (250, 200)
28
- labels = class_labels
29
  model_vgg19 = onnxruntime.InferenceSession(onnx_model_vgg19_path)
30
 
31
  elif model == "Vgg16":
32
- img_size = (150, 150)
33
- labels = class_labels2
34
  model_vgg16 = onnxruntime.InferenceSession(onnx_model_vgg16_path)
35
 
36
  img = cv2.imread(image_path)
@@ -74,6 +69,7 @@ interface_image = gr.Interface(
74
  inputs=inputs_image,
75
  fn=predict_image,
76
  outputs=outputs_text,
77
- title="classifier_demo"
 
78
  )
79
  interface_image.launch()
 
6
  onnx_model_vgg19_path = "./vgg19-30epochs.onnx"
7
  onnx_model_inceptionv3_path = "./InceptionV3-20epochs.onnx"
8
  onnx_model_resnet101_path = "./Resnet101-30epochs.onnx"
9
+ onnx_model_vgg16_path = "./vgg16-20epochs.onnx"
10
 
11
 
12
 
13
+ labels = ['Ajloun Castle', 'Hadrians Arch', 'Petra-siq', 'Roman Ruins-Jerash', 'Roman amphitheater', 'The Cardo Maximus of Jerash', 'Wadi Rum', 'petra-Treasury', 'umm qais']
 
14
 
15
  def predict_image(image_path, model):
16
 
17
  if model == "InceptionV3":
18
  img_size = (550, 475)
 
19
  model_inceptionv3 = onnxruntime.InferenceSession(onnx_model_inceptionv3_path)
20
  elif model == "Resnet101":
21
  img_size = (250, 200)
 
22
  model_resnet101 = onnxruntime.InferenceSession(onnx_model_resnet101_path)
23
  elif model == "Vgg19":
24
  img_size = (250, 200)
 
25
  model_vgg19 = onnxruntime.InferenceSession(onnx_model_vgg19_path)
26
 
27
  elif model == "Vgg16":
28
+ img_size = (200, 150)
 
29
  model_vgg16 = onnxruntime.InferenceSession(onnx_model_vgg16_path)
30
 
31
  img = cv2.imread(image_path)
 
69
  inputs=inputs_image,
70
  fn=predict_image,
71
  outputs=outputs_text,
72
+ title="classifier_demo",
73
+
74
  )
75
  interface_image.launch()