Spaces:
Sleeping
Sleeping
Initial Commit
Browse files- app.py +30 -0
- examples/aculus_1.jpg +0 -0
- examples/aculus_2.jpg +0 -0
- examples/healthy.jpg +0 -0
- examples/peacock_1.jpeg +0 -0
- examples/peacock_2.jpg +0 -0
- examples/peacock_3.jpg +0 -0
- olive-classifier.pth +3 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import timm
|
3 |
+
|
4 |
+
model = timm.create_model("MobileOne_s2", pretrained = False)
|
5 |
+
model.head.fc = nn.Linear(model.head.fc.in_features,3)
|
6 |
+
model.load_state_dict(torch.load("olive_classifier.pth", weights_only=True))
|
7 |
+
model.eval()
|
8 |
+
|
9 |
+
categories = ("Aculus Olearius", "Healthy", "Peacock Spot")
|
10 |
+
|
11 |
+
|
12 |
+
def classify_health(input_img):
|
13 |
+
probs = model(input_img)
|
14 |
+
idx = probs.argmax()
|
15 |
+
return dict(zip(categories, map(float, probs)))
|
16 |
+
|
17 |
+
|
18 |
+
labels = gr.Label()
|
19 |
+
examples = [
|
20 |
+
"examples/healthy.jpg",
|
21 |
+
"examples/aculus_2.jpg",
|
22 |
+
"examples/peacock_3.jpeg",
|
23 |
+
]
|
24 |
+
demo = gr.Interface(
|
25 |
+
classify_health,
|
26 |
+
inputs=gr.Image(height=224, width=224),
|
27 |
+
outputs=labels,
|
28 |
+
examples=examples,
|
29 |
+
)
|
30 |
+
demo.launch(inline=False)
|
examples/aculus_1.jpg
ADDED
![]() |
examples/aculus_2.jpg
ADDED
![]() |
examples/healthy.jpg
ADDED
![]() |
examples/peacock_1.jpeg
ADDED
![]() |
examples/peacock_2.jpg
ADDED
![]() |
examples/peacock_3.jpg
ADDED
![]() |
olive-classifier.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25c66a2ae9d983f1f2d21fbd9a76637991541b821a78dbd5db5879aa521b32ce
|
3 |
+
size 23940298
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==4.43.0
|
2 |
+
torchvision==0.19.0
|
3 |
+
timm==1.0.9
|
4 |
+
torch==2.4.0
|