|  | import numpy as np | 
					
						
						|  | from tensorflow.keras.preprocessing import image | 
					
						
						|  | import gradio as gr | 
					
						
						|  | import numpy as np | 
					
						
						|  | from tensorflow.keras.preprocessing import image | 
					
						
						|  | import gradio as gr | 
					
						
						|  | import keras | 
					
						
						|  |  | 
					
						
						|  | model = keras.models.load_model('x_ray.keras') | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | def classify_image(img): | 
					
						
						|  |  | 
					
						
						|  | img_width, img_height = 150, 150 | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | img = img.resize((img_width, img_height)) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | img = np.array(img) | 
					
						
						|  | img = img.astype('float32') / 255.0 | 
					
						
						|  | img = np.expand_dims(img, axis=0) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | prediction = model.predict(img) | 
					
						
						|  |  | 
					
						
						|  | return "NOT fractured" if prediction > 0.5 else "fractured" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | iface = gr.Interface( | 
					
						
						|  | fn=classify_image, | 
					
						
						|  | inputs=gr.inputs.Image(type="pil", label="Upload an X-ray image"), | 
					
						
						|  | outputs="text", | 
					
						
						|  | title="Bone Fracture Classification", | 
					
						
						|  | description="Upload an X-ray image, and this model will classify it as fractured or not.", | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | iface.launch() | 
					
						
						|  |  |