Rehman1603 commited on
Commit
ee101bc
·
verified ·
1 Parent(s): ef93cdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -1,11 +1,13 @@
1
  from keras.models import load_model
2
  import cv2
3
  import gradio as gr
 
4
 
5
  pox_model = load_model('fowl_pox_model.keras', compile=True)
6
- class_name={0:'Healthy',1:'Chicken have fowl pox',2:'Unkown'}
7
- status={0:'Non Critical',1:'Critical',2:'N/A'}
8
- recommend={0:'No need medicine',1:'Panadol',2:'N/A'}
 
9
  def predict(img):
10
  # Resize the image to the required size for the model
11
  img_resized = cv2.resize(img, (256, 256))
@@ -47,14 +49,27 @@ def predict(img):
47
  cv2.rectangle(img_with_boxes, (min_x_scaled, min_y_scaled), (max_x_scaled, max_y_scaled), (0, 255, 0), 2)
48
  else:
49
  img_with_boxes = img
 
 
 
 
50
 
51
- return img_with_boxes, prediction_label, prediction_status, recommendation
52
 
53
 
54
- interface=gr.Interface(fn=predict,inputs='image',outputs=['image',gr.components.Textbox(label='Disease Name'),gr.components.Textbox(label='Disease status'),gr.components.Textbox(label='Disease medicine')],
55
- examples=[
56
- ['download (1).jpeg'],['download (2).jpeg'],['download (3).jpeg'],['images (1).jpeg'],['images (2).jpeg'],['images (3).jpeg']
57
- ])
 
 
 
 
 
 
 
 
 
 
 
58
  interface.launch(debug=True)
59
-
60
-
 
1
  from keras.models import load_model
2
  import cv2
3
  import gradio as gr
4
+ import os
5
 
6
  pox_model = load_model('fowl_pox_model.keras', compile=True)
7
+ class_name = {0: 'Healthy', 1: 'Chicken have fowl pox', 2: 'Unknown'}
8
+ status = {0: 'Non Critical', 1: 'Critical', 2: 'N/A'}
9
+ recommend = {0: 'No need medicine', 1: 'Panadol', 2: 'N/A'}
10
+
11
  def predict(img):
12
  # Resize the image to the required size for the model
13
  img_resized = cv2.resize(img, (256, 256))
 
49
  cv2.rectangle(img_with_boxes, (min_x_scaled, min_y_scaled), (max_x_scaled, max_y_scaled), (0, 255, 0), 2)
50
  else:
51
  img_with_boxes = img
52
+
53
+ # Save the output image
54
+ output_path = 'output_image.jpg'
55
+ cv2.imwrite(output_path, img_with_boxes)
56
 
57
+ return img_with_boxes, prediction_label, prediction_status, recommendation, output_path
58
 
59
 
60
+ interface = gr.Interface(
61
+ fn=predict,
62
+ inputs='image',
63
+ outputs=[
64
+ 'image',
65
+ gr.components.Textbox(label='Disease Name'),
66
+ gr.components.Textbox(label='Disease status'),
67
+ gr.components.Textbox(label='Disease medicine'),
68
+ gr.components.File(label='Download Image')
69
+ ],
70
+ examples=[
71
+ ['download (1).jpeg'], ['download (2).jpeg'], ['download (3).jpeg'],
72
+ ['images (1).jpeg'], ['images (2).jpeg'], ['images (3).jpeg']
73
+ ]
74
+ )
75
  interface.launch(debug=True)