Nina-HK commited on
Commit
1eebc45
1 Parent(s): 03af26e
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """gradioApp.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/19rOnZUE7tNaMyAjlhnO4vLKb8mojrf2V
8
+ """
9
+
10
+ # Commented out IPython magic to ensure Python compatibility.
11
+ # %%capture
12
+ # #Use capture to not show the output of installing the libraries!
13
+ # !pip install gradio
14
+
15
+ import gradio as gr
16
+ import numpy as np
17
+ import tensorflow as tf
18
+
19
+ model = tf.keras.models.load_model('/content/drive/MyDrive/project_image_2023_NO/saved_models/saved_model/densenet')
20
+ labels = ['Healthy', 'Patient']
21
+
22
+ def classify_image(inp):
23
+ inp = inp.reshape((-1, 224, 224, 3))
24
+ inp = tf.keras.applications.densenet.preprocess_input(inp)
25
+ prediction = model.predict(inp)
26
+ confidences = {labels[i]: float(prediction[0][i]) for i in range(2)}
27
+ return confidences
28
+
29
+ gr.Interface(fn=classify_image,
30
+ inputs=gr.Image(shape=(224, 224)),
31
+ outputs=gr.Label(num_top_classes = 2),
32
+ title="Demo",
33
+ description="Here's a sample image classification. Enjoy!",
34
+ ).launch(share = True)