Spaces:
Runtime error
Runtime error
source /home/fark/anaconda3/bin/activate base
Browse filesRevert "Revert last commit"
This reverts commit a5fd8341df701d30345e6253a4bb25db22d21a08.
- Processor.py +2 -11
- app.py +2 -1
Processor.py
CHANGED
@@ -10,18 +10,9 @@ class Processor():
|
|
10 |
self.__model = torch.hub.load(
|
11 |
'ultralytics/yolov5', 'yolov5x6', trust_repo=True)
|
12 |
|
13 |
-
def
|
14 |
-
|
15 |
-
class_names = self.__inference.dls.vocab
|
16 |
|
17 |
-
test_dl = self.__inference.dls.test_dl(images)
|
18 |
-
tensors = self.__inference.get_preds(dl=test_dl, with_decoded=True)[2]
|
19 |
-
preds = [int(t.item()) for t in tensors]
|
20 |
-
|
21 |
-
for i in preds:
|
22 |
-
result.append(class_names[i])
|
23 |
-
|
24 |
-
return result
|
25 |
def filter_image(self, image: Image) -> bool:
|
26 |
results = self.__model(image)
|
27 |
results = results.pandas().xyxy[0]
|
|
|
10 |
self.__model = torch.hub.load(
|
11 |
'ultralytics/yolov5', 'yolov5x6', trust_repo=True)
|
12 |
|
13 |
+
def classify_image(self, images: NDArray) -> str:
|
14 |
+
return self.__inference.predict(images)
|
|
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def filter_image(self, image: Image) -> bool:
|
17 |
results = self.__model(image)
|
18 |
results = results.pandas().xyxy[0]
|
app.py
CHANGED
@@ -21,7 +21,8 @@ def process_images(images, processor: Processor):
|
|
21 |
if processor.filter_image(image):
|
22 |
filtered_images.append(np.asarray(image))
|
23 |
|
24 |
-
|
|
|
25 |
|
26 |
outfit = mode(result)
|
27 |
|
|
|
21 |
if processor.filter_image(image):
|
22 |
filtered_images.append(np.asarray(image))
|
23 |
|
24 |
+
for img in filtered_images:
|
25 |
+
result.append(processor.classify_image(img)[0])
|
26 |
|
27 |
outfit = mode(result)
|
28 |
|