Spaces:
Sleeping
Sleeping
Commit
·
b734e06
1
Parent(s):
c9c7e8a
feat: modify interface and add samples
Browse files- .gitignore +1 -0
- app.py +26 -4
- models/car-damage-detection_v1.pkl +3 -0
- test/1.jpg +0 -0
- test/2.jpg +0 -0
- test/3.jpg +0 -0
- test/5.jpg +0 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.venv
|
app.py
CHANGED
@@ -1,7 +1,29 @@
|
|
1 |
-
import gradio
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
demo.launch()
|
|
|
1 |
+
import gradio
|
2 |
|
3 |
+
from pathlib import Path
|
|
|
4 |
|
5 |
+
from fastai.vision.all import (
|
6 |
+
load_learner
|
7 |
+
)
|
8 |
+
import gradio.interface
|
9 |
+
|
10 |
+
|
11 |
+
CATEGORIES = ('Damaged', 'Whole')
|
12 |
+
MODEL_PATH = Path('.') / 'models'
|
13 |
+
TEST_IMAGES_PATH = Path('.') / 'test'
|
14 |
+
LEARNER = load_learner(MODEL_PATH / 'car-damage-detection_v1.pkl')
|
15 |
+
|
16 |
+
|
17 |
+
def categorize_image(image):
|
18 |
+
prediction, index, probabilities = LEARNER.predict(image)
|
19 |
+
return dict(zip(CATEGORIES, map(float, probabilities)))
|
20 |
+
|
21 |
+
|
22 |
+
print([image for image in TEST_IMAGES_PATH.ls()])
|
23 |
+
demo = gradio.Interface(
|
24 |
+
categorize_image,
|
25 |
+
inputs='image',
|
26 |
+
outputs='label',
|
27 |
+
examples=[image for image in TEST_IMAGES_PATH]
|
28 |
+
)
|
29 |
demo.launch()
|
models/car-damage-detection_v1.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c5dd4ec7a048e667ce711de250fb1df73ba68b6f799c248e2e17d070c770eee0
|
3 |
+
size 87513070
|
test/1.jpg
ADDED
![]() |
test/2.jpg
ADDED
![]() |
test/3.jpg
ADDED
![]() |
test/5.jpg
ADDED
![]() |