sindhoorar
commited on
Commit
•
4744f93
1
Parent(s):
95ce4f3
Initial Commit
Browse files
model
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from tensorflow.keras.models import load_model
|
3 |
+
from tensorflow.keras.preprocessing import image
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
# Load the model
|
7 |
+
model = load_model('best_model.h5')
|
8 |
+
|
9 |
+
def classify_image(inp):
|
10 |
+
inp = inp.reshape((-1, 224, 224, 3))
|
11 |
+
inp = preprocess_input(inp)
|
12 |
+
prediction = model.predict(inp).flatten()
|
13 |
+
return {f"Class {i}": float(prediction[i]) for i in range(2)}
|
14 |
+
|
15 |
+
image = gr.inputs.Image(shape=(224, 224))
|
16 |
+
label = gr.outputs.Label(num_top_classes=2)
|
17 |
+
|
18 |
+
gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True).launch()
|