Spaces:
Sleeping
Sleeping
Commit
·
95e13a1
1
Parent(s):
5435fea
Upload 2 files
Browse files- app.py +24 -0
- nihal_model.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.widgets import *
|
3 |
+
from fastcore.all import *
|
4 |
+
from fastai.vision.all import *
|
5 |
+
|
6 |
+
def classify_image(img):
|
7 |
+
learn = load_learner('nihal_model.pkl')
|
8 |
+
pred,pred_idx,probs = learn.predict(img)
|
9 |
+
#return both the prediction and the probability either nihal or not and format in perccentage
|
10 |
+
return pred, "{:.0%}".format(float(probs[pred_idx])),float(probs[~pred_idx])
|
11 |
+
#return f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'
|
12 |
+
|
13 |
+
|
14 |
+
if __name__ == '__main__':
|
15 |
+
# Define inputs and outputs for Gradio interface
|
16 |
+
inputs = [gr.Image(type="pil", label="Select an image of Nihal")]
|
17 |
+
outputs = [
|
18 |
+
gr.Label(""),
|
19 |
+
gr.Label(label="Confidence"),
|
20 |
+
]
|
21 |
+
|
22 |
+
# Launch the Gradio interface
|
23 |
+
interface = gr.Interface(fn=classify_image, inputs=inputs, outputs=outputs)
|
24 |
+
interface.launch()
|
nihal_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4fc562781d4d8b35f72802117e0f1b50ed654f87e4349cf0d54db606e88a3cdf
|
3 |
+
size 87480610
|