amit-asl
commited on
Commit
·
666fd3d
1
Parent(s):
560022f
init
Browse files- croc.jpg +0 -0
- export.pkl +3 -0
- main.py +32 -0
- requirements.txt +3 -0
croc.jpg
ADDED
![]() |
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ba47f0a8121f047aa472be188b050b9253aee0975b6900aacbc37b60eb37ef5e
|
3 |
+
size 161268396
|
main.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
from fastai.vision.all import *
|
4 |
+
|
5 |
+
def predict_image(image):
|
6 |
+
learner = learner_load('export.pkl')
|
7 |
+
img = PILImage.create(image)
|
8 |
+
pred = learner.predict(img)
|
9 |
+
return pred[0]
|
10 |
+
|
11 |
+
|
12 |
+
def create_interface():
|
13 |
+
|
14 |
+
image_input = gr.inputs.Image()
|
15 |
+
|
16 |
+
output = gr.outputs.Text()
|
17 |
+
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=predict_image,
|
20 |
+
inputs=image_input,
|
21 |
+
outputs=output,
|
22 |
+
capture_session=True,
|
23 |
+
title="Cat or Dog Classifier",
|
24 |
+
description="Upload an image to classify whether it's a cat or a dog."
|
25 |
+
)
|
26 |
+
return iface
|
27 |
+
|
28 |
+
if __name__ == "__main__":
|
29 |
+
iface = create_interface()
|
30 |
+
iface.launch()
|
31 |
+
|
32 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
pillow
|
3 |
+
fastai
|