radub23
commited on
Commit
·
76a82c9
1
Parent(s):
963e913
Add get_labels function required by the model and update dependencies
Browse files- app.py +13 -0
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
from fastai.vision.all import *
|
| 3 |
from fastai.learner import load_learner
|
| 4 |
from pathlib import Path
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
"""
|
|
@@ -9,6 +10,18 @@ Warning Lamp Detector using FastAI
|
|
| 9 |
This application allows users to upload images of warning lamps and get classification results.
|
| 10 |
"""
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Load the FastAI model
|
| 13 |
try:
|
| 14 |
model_path = Path("WarningLampClassifier.pkl")
|
|
|
|
| 2 |
from fastai.vision.all import *
|
| 3 |
from fastai.learner import load_learner
|
| 4 |
from pathlib import Path
|
| 5 |
+
import pandas as pd
|
| 6 |
import os
|
| 7 |
|
| 8 |
"""
|
|
|
|
| 10 |
This application allows users to upload images of warning lamps and get classification results.
|
| 11 |
"""
|
| 12 |
|
| 13 |
+
def get_labels(fname):
|
| 14 |
+
"""
|
| 15 |
+
Function required by the model to process labels
|
| 16 |
+
Args:
|
| 17 |
+
fname: Path to the image file
|
| 18 |
+
Returns:
|
| 19 |
+
list: List of active labels
|
| 20 |
+
"""
|
| 21 |
+
# Since we're only doing inference, we can return an empty list
|
| 22 |
+
# This function is only needed because the model was saved with it
|
| 23 |
+
return []
|
| 24 |
+
|
| 25 |
# Load the FastAI model
|
| 26 |
try:
|
| 27 |
model_path = Path("WarningLampClassifier.pkl")
|
requirements.txt
CHANGED
|
@@ -3,4 +3,5 @@ huggingface-hub>=0.20.3
|
|
| 3 |
Pillow>=10.0.0 # Required for image processing
|
| 4 |
fastai>=2.7.13 # Required for model inference
|
| 5 |
torch>=2.2.0 # Required by FastAI
|
| 6 |
-
torchvision>=0.17.0 # Required by FastAI
|
|
|
|
|
|
| 3 |
Pillow>=10.0.0 # Required for image processing
|
| 4 |
fastai>=2.7.13 # Required for model inference
|
| 5 |
torch>=2.2.0 # Required by FastAI
|
| 6 |
+
torchvision>=0.17.0 # Required by FastAI
|
| 7 |
+
pandas>=2.0.0 # Required for data processing
|