Spaces:
Sleeping
Sleeping
create catvsdog.py
Browse files- catvsdog.py +28 -0
catvsdog.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import numpy as np # linear algebra
|
3 |
+
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
|
4 |
+
|
5 |
+
import os
|
6 |
+
for dirname, _, filenames in os.walk('/kaggle/input'):
|
7 |
+
for filename in filenames:
|
8 |
+
print(os.path.join(dirname, filename))
|
9 |
+
|
10 |
+
from fastai.vision.all import *
|
11 |
+
import gradio as gr
|
12 |
+
|
13 |
+
share = True
|
14 |
+
def is_cat(x): return x[0].isupper()
|
15 |
+
|
16 |
+
learn = load_learner('/kaggle/input/cvd1/pytorch/default/1/model.pkl')
|
17 |
+
|
18 |
+
categories = ('Dog', 'Cat')
|
19 |
+
|
20 |
+
def classify_image(img):
|
21 |
+
pred,idx,probs = learn.predict(img)
|
22 |
+
return dict(zip(categories, map(float, probs)))
|
23 |
+
|
24 |
+
image = "image"
|
25 |
+
label = "label"
|
26 |
+
|
27 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
|
28 |
+
intf.launch(inline=False, share = True)
|