Spaces:
Runtime error
Runtime error
Commit
·
70fdee2
1
Parent(s):
3c123d7
fix
Browse files
app.py
CHANGED
|
@@ -4,6 +4,10 @@ import gradio as gr
|
|
| 4 |
import numpy as np
|
| 5 |
from fastai.vision.all import *
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
config = {
|
| 8 |
"labels": [
|
| 9 |
"Plantation",
|
|
@@ -13,11 +17,12 @@ config = {
|
|
| 13 |
"size": 256,
|
| 14 |
}
|
| 15 |
|
|
|
|
|
|
|
| 16 |
learn = load_learner("model.pkl")
|
| 17 |
|
| 18 |
def classify_image(input):
|
| 19 |
_, _, prediction = learn.predict(input)
|
| 20 |
-
print(prediction)
|
| 21 |
outputs = {label: float(prediction[i]) for i, label in enumerate(config["labels"])}
|
| 22 |
# Get argmax
|
| 23 |
argmax_label = config["labels"][np.argmax(prediction)]
|
|
@@ -31,7 +36,7 @@ gr.Interface(
|
|
| 31 |
gr.outputs.Textbox(label="Output of the model"),
|
| 32 |
gr.outputs.Textbox(label="Probability (0 - 100)")
|
| 33 |
],
|
| 34 |
-
examples=[str(x) for x in Path("./").glob("*.
|
| 35 |
flagging_options=["Correct label", "Incorrect label"],
|
| 36 |
allow_flagging="manual",
|
| 37 |
).launch()
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
from fastai.vision.all import *
|
| 6 |
|
| 7 |
+
|
| 8 |
+
def label(file_name):
|
| 9 |
+
return train_labels[file_name.replace(".jpg", "")]
|
| 10 |
+
|
| 11 |
config = {
|
| 12 |
"labels": [
|
| 13 |
"Plantation",
|
|
|
|
| 17 |
"size": 256,
|
| 18 |
}
|
| 19 |
|
| 20 |
+
|
| 21 |
+
|
| 22 |
learn = load_learner("model.pkl")
|
| 23 |
|
| 24 |
def classify_image(input):
|
| 25 |
_, _, prediction = learn.predict(input)
|
|
|
|
| 26 |
outputs = {label: float(prediction[i]) for i, label in enumerate(config["labels"])}
|
| 27 |
# Get argmax
|
| 28 |
argmax_label = config["labels"][np.argmax(prediction)]
|
|
|
|
| 36 |
gr.outputs.Textbox(label="Output of the model"),
|
| 37 |
gr.outputs.Textbox(label="Probability (0 - 100)")
|
| 38 |
],
|
| 39 |
+
examples=[str(x) for x in Path("./").glob("*.png")],
|
| 40 |
flagging_options=["Correct label", "Incorrect label"],
|
| 41 |
allow_flagging="manual",
|
| 42 |
).launch()
|