Spaces:
Sleeping
Sleeping
Preparing submission
Browse files- Dockerfile +2 -2
- README.md +14 -25
- requirements.txt +3 -0
- tasks/image.py +22 -12
- tasks/models/pruned.pt +0 -3
- tasks/models/{best.pt → pruned_fp16.pt} +2 -2
Dockerfile
CHANGED
@@ -11,8 +11,8 @@ WORKDIR /app
|
|
11 |
|
12 |
COPY --chown=user ./requirements.txt requirements.txt
|
13 |
|
14 |
-
# Needed
|
15 |
-
RUN pip install ultralytics
|
16 |
RUN pip install opencv-python-headless
|
17 |
|
18 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
|
11 |
|
12 |
COPY --chown=user ./requirements.txt requirements.txt
|
13 |
|
14 |
+
# Needed here instead of requirements.txt, because of dependency errors of opencv
|
15 |
+
RUN pip install ultralytics==8.3.69
|
16 |
RUN pip install opencv-python-headless
|
17 |
|
18 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
README.md
CHANGED
@@ -8,45 +8,39 @@ pinned: false
|
|
8 |
---
|
9 |
|
10 |
|
11 |
-
#
|
12 |
|
13 |
## Model Description
|
14 |
|
15 |
-
This is a
|
16 |
|
17 |
### Intended Use
|
18 |
|
19 |
-
- **Primary intended uses**:
|
20 |
- **Primary intended users**: Researchers and developers participating in the Frugal AI Challenge
|
21 |
-
- **Out-of-scope use cases**: Not intended for production use or real-world classification tasks
|
22 |
|
23 |
## Training Data
|
24 |
|
25 |
-
The model uses the
|
26 |
-
- Size: ~
|
27 |
-
- Split:
|
28 |
-
-
|
29 |
|
30 |
### Labels
|
31 |
-
|
32 |
-
1. Global warming is not happening
|
33 |
-
2. Not caused by humans
|
34 |
-
3. Not bad or beneficial
|
35 |
-
4. Solutions harmful/unnecessary
|
36 |
-
5. Science is unreliable
|
37 |
-
6. Proponents are biased
|
38 |
-
7. Fossil fuels are needed
|
39 |
|
40 |
## Performance
|
41 |
|
42 |
### Metrics
|
43 |
-
- **Accuracy**: ~
|
44 |
- **Environmental Impact**:
|
45 |
- Emissions tracked in gCO2eq
|
46 |
- Energy consumption tracked in Wh
|
47 |
|
48 |
### Model Architecture
|
49 |
-
|
|
|
|
|
50 |
|
51 |
## Environmental Impact
|
52 |
|
@@ -57,15 +51,10 @@ Environmental impact is tracked using CodeCarbon, measuring:
|
|
57 |
This tracking helps establish a baseline for the environmental impact of model deployment and inference.
|
58 |
|
59 |
## Limitations
|
60 |
-
-
|
61 |
-
-
|
62 |
-
- No consideration of input text
|
63 |
-
- Serves only as a baseline reference
|
64 |
-
- Not suitable for any real-world applications
|
65 |
|
66 |
## Ethical Considerations
|
67 |
|
68 |
-
- Dataset contains sensitive topics related to climate disinformation
|
69 |
-
- Model makes random predictions and should not be used for actual classification
|
70 |
- Environmental impact is tracked to promote awareness of AI's carbon footprint
|
71 |
```
|
|
|
8 |
---
|
9 |
|
10 |
|
11 |
+
# Object Detector for forest fire smoke
|
12 |
|
13 |
## Model Description
|
14 |
|
15 |
+
This is a frugal object detector use to detect fire smoke, as part of the Frugal AI Challenge 2024. It is based of the yolo model series
|
16 |
|
17 |
### Intended Use
|
18 |
|
19 |
+
- **Primary intended uses**: Detect fire smoke on photos of forests, in different natural settings
|
20 |
- **Primary intended users**: Researchers and developers participating in the Frugal AI Challenge
|
|
|
21 |
|
22 |
## Training Data
|
23 |
|
24 |
+
The model uses the pyronear/pyro-sdis dataset:
|
25 |
+
- Size: ~33 600 examples
|
26 |
+
- Split: 88% train, 12% test
|
27 |
+
- Images with smoke or no smoke
|
28 |
|
29 |
### Labels
|
30 |
+
Smoke
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
## Performance
|
33 |
|
34 |
### Metrics
|
35 |
+
- **Accuracy**: ~ 90%
|
36 |
- **Environmental Impact**:
|
37 |
- Emissions tracked in gCO2eq
|
38 |
- Energy consumption tracked in Wh
|
39 |
|
40 |
### Model Architecture
|
41 |
+
Based of YOLOv11, see https://arxiv.org/abs/2410.17725, fine tuned on the pyronear dataset. The network is pruned and quantized to be as compressed as possible.
|
42 |
+
|
43 |
+
Inference should ideally performed on GPU - the speed bump is drastic, it is more energy efficient than CPU inference which takes much longer.
|
44 |
|
45 |
## Environmental Impact
|
46 |
|
|
|
51 |
This tracking helps establish a baseline for the environmental impact of model deployment and inference.
|
52 |
|
53 |
## Limitations
|
54 |
+
- Quantization was performed to FP16 - INT8 could compress even more but the accuracy drop was too big. Finding a way to smartly quantize and calibrate to INT8 could be interesting
|
55 |
+
- To maximize inference speed even more, the model can be converted to TensorRT - it is note done in this repository, as the same type of GPU needs to be used both for exporting to TensorRT and inferencing with TensorRT
|
|
|
|
|
|
|
56 |
|
57 |
## Ethical Considerations
|
58 |
|
|
|
|
|
59 |
- Environmental impact is tracked to promote awareness of AI's carbon footprint
|
60 |
```
|
requirements.txt
CHANGED
@@ -12,3 +12,6 @@ requests>=2.31.0
|
|
12 |
librosa==0.10.2.post1
|
13 |
torch==2.5.1
|
14 |
torchvision==0.20.1
|
|
|
|
|
|
|
|
12 |
librosa==0.10.2.post1
|
13 |
torch==2.5.1
|
14 |
torchvision==0.20.1
|
15 |
+
onnx==1.17.0
|
16 |
+
onnxslim==0.1.48
|
17 |
+
onnxruntime==1.20.1
|
tasks/image.py
CHANGED
@@ -97,16 +97,31 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
97 |
# YOUR MODEL INFERENCE CODE HERE
|
98 |
# Update the code below to replace the random baseline with your model inference
|
99 |
#--------------------------------------------------------------------------------------------
|
|
|
100 |
from pathlib import Path
|
101 |
from ultralytics import YOLO
|
102 |
-
import
|
|
|
|
|
|
|
103 |
|
104 |
# Load model
|
105 |
model_path = Path("tasks", "models")
|
106 |
-
#
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
predictions = []
|
112 |
true_labels = []
|
@@ -120,13 +135,8 @@ async def evaluate_image(request: ImageEvaluationRequest):
|
|
120 |
true_labels.append(int(has_smoke))
|
121 |
|
122 |
# Make prediction
|
123 |
-
|
124 |
-
|
125 |
-
if results.boxes.cls.numel()!=0:
|
126 |
-
# This means a fire was detected, hence we append 1
|
127 |
-
pred_has_smoke = 1
|
128 |
-
else:
|
129 |
-
pred_has_smoke = 0
|
130 |
predictions.append(int(pred_has_smoke))
|
131 |
|
132 |
# If there's a true box, parse it and add box prediction
|
|
|
97 |
# YOUR MODEL INFERENCE CODE HERE
|
98 |
# Update the code below to replace the random baseline with your model inference
|
99 |
#--------------------------------------------------------------------------------------------
|
100 |
+
# Import strict minimum
|
101 |
from pathlib import Path
|
102 |
from ultralytics import YOLO
|
103 |
+
from torch import device
|
104 |
+
from torch.cuda import is_available
|
105 |
+
|
106 |
+
THRESHOLD = 0.18
|
107 |
|
108 |
# Load model
|
109 |
model_path = Path("tasks", "models")
|
110 |
+
# If CUDA is available, load FP16 pytorch
|
111 |
+
# if is_available():
|
112 |
+
# print("CUDA available, loading FP16 pytorch model")
|
113 |
+
model_name = "pruned_fp16.pt"
|
114 |
+
model = YOLO(Path(model_path, model_name), task="detect")
|
115 |
+
# device = device("cuda")
|
116 |
+
device_name = device("cuda" if is_available() else "cpu")
|
117 |
+
IMGSIZE = 1280
|
118 |
+
# # If not, load FP16 ONNX model
|
119 |
+
# else:
|
120 |
+
# print("CUDA not, available, loading ONNX model")
|
121 |
+
# model_name = "640_fp16_cpu.onnx"
|
122 |
+
# model = YOLO(Path(model_path, model_name), task="detect")
|
123 |
+
# device = device("cpu")
|
124 |
+
# IMGSIZE = 640 # required to make CPU inference a bit fast
|
125 |
|
126 |
predictions = []
|
127 |
true_labels = []
|
|
|
135 |
true_labels.append(int(has_smoke))
|
136 |
|
137 |
# Make prediction
|
138 |
+
results = model.predict(example["image"], device=device_name, conf=THRESHOLD, verbose=False, imgsz=IMGSIZE)[0]
|
139 |
+
pred_has_smoke = len(results) > 0
|
|
|
|
|
|
|
|
|
|
|
140 |
predictions.append(int(pred_has_smoke))
|
141 |
|
142 |
# If there's a true box, parse it and add box prediction
|
tasks/models/pruned.pt
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:0e5e9ef2d0bbe8e8984d6739ccc2d21045844c2be98425b271090de621042ce8
|
3 |
-
size 5470665
|
|
|
|
|
|
|
|
tasks/models/{best.pt → pruned_fp16.pt}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b39f8abf26409f62ce689af44095cfd8debd183eae3a83b18729d6e826fce51a
|
3 |
+
size 5558000
|