CNN-RESNET50
commited on
Commit
•
9d97baa
1
Parent(s):
0cbeb0d
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import PIL
|
4 |
+
import tensorflow as tf
|
5 |
+
from tensorflow import keras
|
6 |
+
from keras import layers
|
7 |
+
from keras.models import Sequential
|
8 |
+
from keras.preprocessing.image import ImageDataGenerator
|
9 |
+
import pathlib
|
10 |
+
from keras.models import Model
|
11 |
+
from PIL import Image
|
12 |
+
|
13 |
+
model = keras.models.load_model('model.h5')
|
14 |
+
class_names = ['sea', 'glacier']
|
15 |
+
|
16 |
+
def predict_image(img):
|
17 |
+
img_4d=img.reshape(1,224,224,3)
|
18 |
+
prediction=model.predict(img_4d)[0]
|
19 |
+
return {class_names[i]: float(prediction[i]) for i in range(2)}
|
20 |
+
|
21 |
+
image = gr.inputs.Image(shape=(224,224))
|
22 |
+
label = gr.outputs.Label(num_top_classes=2)
|
23 |
+
|
24 |
+
gr.Interface(css=None,
|
25 |
+
fn=predict_image,
|
26 |
+
inputs=image,
|
27 |
+
description="Please upload a Chest X-Ray image in JPG, JPEG or PNG.",
|
28 |
+
title='Identifying Adenoid by Convolutional neural network',outputs=label).launch(share=None)
|
29 |
+
|
30 |
+
gr.launch()
|