AbdullahAj2000 commited on
Commit
b80bbad
·
verified ·
1 Parent(s): 97064da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -44
app.py CHANGED
@@ -10,51 +10,7 @@ import gradio as gr
10
  #model = tf.keras.models.load_model("./models/last_Vgg19.h5")\
11
  model = ort.InferenceSession('./models/VGG19_32_onnx.onnx')
12
 
13
- def mux(pred):
14
- index = np.array(pred).argmax()
15
- if index ==0:
16
- return "Ajloun Castle",max(pred)
17
- elif index == 1 or index == 2:
18
- return "Jerash",max(pred)
19
- elif index == 3:
20
- return "Petra",max(pred)
21
- elif index == 4:
22
- return "Roman amphitheater",max(pred)
23
- elif index == 5:
24
- return "Umm Qais",max(pred)
25
- elif index == 6:
26
- return "Wadi Rum",max(pred)
27
 
28
- def show_preds_image(image_path):
29
- img = cv2.imread(image_path)
30
- img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
31
- img = cv2.resize(img, (224, 224))
32
- img_array = img / 255.0
33
- img_array = img_array.reshape(1, 224, 224, 3)
34
-
35
- # Assume 'model' is already loaded and ready for inference
36
-
37
- # Run the model
38
- input_name = model.get_inputs()[0].name
39
- output_name = model.get_outputs()[0].name
40
- outputs = model.run(None, {input_name: img_array})
41
-
42
- # Get predicted class
43
- predicted_class_index = int(outputs[0].argmax(axis=1))
44
-
45
- # Define classes
46
- classes = ['Ajloun Castle', 'Jerash', 'Jerash', 'Petra', 'Roman amphitheater', 'Roman amphitheater', 'Wadi Rum']
47
- predicted_class = classes[predicted_class_index]
48
-
49
- # Display the result using OpenCV
50
- mux_value = f'{predicted_class}:{outputs[0][0][predicted_class_index]}'
51
- height, width, _ = img.shape
52
- text_x = int((width - len(mux_value) * 10) / 2)
53
- text_y = int(height / 2)
54
- font_scale = 2
55
- cv2.putText(img, mux_value, (text_x, text_y), cv2.FONT_HERSHEY_SIMPLEX, font_scale, (255, 0, 0), 2, cv2.LINE_AA)
56
-
57
- return img
58
 
59
  inputs_image = [
60
  gr.components.Image(type="filepath", label="Input Image"),
 
10
  #model = tf.keras.models.load_model("./models/last_Vgg19.h5")\
11
  model = ort.InferenceSession('./models/VGG19_32_onnx.onnx')
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  inputs_image = [
16
  gr.components.Image(type="filepath", label="Input Image"),