Update app.py
Browse files
app.py
CHANGED
@@ -9,29 +9,25 @@ import gradio as gr
|
|
9 |
import pathlib
|
10 |
import platform
|
11 |
|
12 |
-
|
13 |
def whichBear(x): return x[0].isBear()
|
14 |
|
15 |
# %% app.ipynb 4
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
-
#
|
19 |
-
|
20 |
-
pathlib.PosixPath = pathlib.WindowsPath
|
21 |
|
22 |
# Load the learner
|
23 |
learn = load_learner("model.pkl")
|
24 |
|
25 |
-
# Restore the original PosixPath class
|
26 |
-
if platform.system().lower() != "windows":
|
27 |
-
pathlib.PosixPath = original_posix_path
|
28 |
-
|
29 |
-
|
30 |
# %% app.ipynb 6
|
31 |
options = ("grizzly", "black", "teddy")
|
32 |
|
33 |
def classify_img(img):
|
34 |
-
pred,idx,probs = learn.predict(img)
|
35 |
return dict(zip(options, map(float, probs)))
|
36 |
|
37 |
# %% app.ipynb 8
|
|
|
9 |
import pathlib
|
10 |
import platform
|
11 |
|
|
|
12 |
def whichBear(x): return x[0].isBear()
|
13 |
|
14 |
# %% app.ipynb 4
|
15 |
+
# Function to handle the path conversion if necessary
|
16 |
+
def fix_path():
|
17 |
+
if platform.system().lower() != "windows":
|
18 |
+
pathlib.WindowsPath = pathlib.PosixPath
|
19 |
|
20 |
+
# Call the function to fix path handling before loading the model
|
21 |
+
fix_path()
|
|
|
22 |
|
23 |
# Load the learner
|
24 |
learn = load_learner("model.pkl")
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
# %% app.ipynb 6
|
27 |
options = ("grizzly", "black", "teddy")
|
28 |
|
29 |
def classify_img(img):
|
30 |
+
pred, idx, probs = learn.predict(img)
|
31 |
return dict(zip(options, map(float, probs)))
|
32 |
|
33 |
# %% app.ipynb 8
|