tanvir-ishraq
commited on
Commit
•
c3ba044
1
Parent(s):
4a96b3e
Upload 4 files
Browse files- README.md +2 -2
- app.py +49 -4
- models/ARMOR-classifier-v4.pkl +3 -0
- requirements.txt +7 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: A.R.M.O.R classifier - Armament Models Recognizer for Military Security
|
3 |
+
emoji: 🛡️
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
app.py
CHANGED
@@ -1,7 +1,52 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
#to use load_learner() in windows: #get updated code from discord group
|
5 |
+
# import pathlib
|
6 |
+
# temp = pathlib.PosixPath
|
7 |
+
# pathlib.PosixPath = pathlib.WindowsPath
|
8 |
|
9 |
+
cap_labels = (
|
10 |
+
'2S19 Msta artillery',
|
11 |
+
'BM-21 Grad artillery',
|
12 |
+
'BMP-2 vehicle',
|
13 |
+
'BTR-80 vehicle',
|
14 |
+
'Bayraktar TB2 UVAC drone',
|
15 |
+
'CH-5 Rainbow UVAC drone',
|
16 |
+
'G6 Rhino artillery',
|
17 |
+
'Hermes 900 drone', 'Heron TP drone',
|
18 |
+
'Humvee vehicle',
|
19 |
+
'LAV-25 vehicle',
|
20 |
+
'Leopard 2 tank',
|
21 |
+
'M1 Abrams tank',
|
22 |
+
'M109 artillery',
|
23 |
+
'M113 vehicle', 'M270 MLRS artillery',
|
24 |
+
'MQ-9 Reaper UVAC drone',
|
25 |
+
'MRAP vehicle',
|
26 |
+
'RQ-4 Global Hawk UVAC drone',
|
27 |
+
'T-72 tank',
|
28 |
+
'Type 99 tank', 'smerch artillery'
|
29 |
+
)
|
30 |
+
|
31 |
+
model = load_learner('models/ARMOR-classifier-v4.pkl')
|
32 |
+
|
33 |
+
def recognize_image(image):
|
34 |
+
pred, idx, probs = model.predict(image) #predict() returns category, it's index, probablity of all catg.
|
35 |
+
# print(pred)
|
36 |
+
return dict(zip(cap_labels, map(float, probs))) # for all categories
|
37 |
+
|
38 |
+
#input output gradio formatting set:
|
39 |
+
image = gr.inputs.Image(shape=(192,192))
|
40 |
+
label = gr.outputs.Label(num_top_classes=5)
|
41 |
+
#Answeres: bm21, humvee, t72, leopard 2, mq-9
|
42 |
+
examples = [
|
43 |
+
'test_images/unknown_00.jpeg',
|
44 |
+
'test_images/unknown_01.jpg',
|
45 |
+
'test_images/unknown_02.jpg',
|
46 |
+
'test_images/unknown_03.webp',
|
47 |
+
'test_images/unknown_04.jpg'
|
48 |
+
]
|
49 |
+
|
50 |
+
#interface with i/o
|
51 |
+
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
|
52 |
+
iface.launch(inline=False) # share=True for colab
|
models/ARMOR-classifier-v4.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a51748334cad662b838dfd0a4b65c01e37aef0eda537de161d823e4a5d6da4ea
|
3 |
+
size 242243669
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastai==2.7.12
|
2 |
+
fastapi==0.98.0
|
3 |
+
fastcore==1.5.29
|
4 |
+
fastdownload==0.0.7
|
5 |
+
fastprogress==1.0.3
|
6 |
+
gradio==3.34.0
|
7 |
+
gradio_client==0.2.6
|