Spaces:
Sleeping
Sleeping
Commit
·
8b179ce
1
Parent(s):
4d56ecd
Fix: comment irrelevant codebase
Browse files
yolov5.py
CHANGED
@@ -82,7 +82,7 @@ def xai_yolov5(image):
|
|
82 |
return Image.fromarray(final_image), caption
|
83 |
|
84 |
|
85 |
-
|
86 |
import yaml
|
87 |
import torch
|
88 |
import warnings
|
@@ -104,7 +104,7 @@ std = [0.229, 0.224, 0.225] # Standard deviation for RGB channels
|
|
104 |
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True).to(device)
|
105 |
print(f"Loaded YOLOv5 model on {device}")
|
106 |
def create_labels(concept_scores, top_k=2):
|
107 |
-
|
108 |
yolov5_categories_url = \
|
109 |
"https://github.com/ultralytics/yolov5/raw/master/data/coco128.yaml" # URL to the YOLOv5 categories file
|
110 |
yaml_data = requests.get(yolov5_categories_url).text
|
@@ -123,9 +123,7 @@ def create_labels(concept_scores, top_k=2):
|
|
123 |
return concept_labels_topk
|
124 |
|
125 |
def get_image_from_url(url, device):
|
126 |
-
|
127 |
-
and returns a numpy image and a preprocessed
|
128 |
-
torch tensor ready to pass to the model"""
|
129 |
|
130 |
img = np.array(Image.open(os.path.join(os.getcwd(), "data/xai/sample1.jpeg")))
|
131 |
img = cv2.resize(img, (640, 640))
|
@@ -170,3 +168,4 @@ def visualize_image(model, img_url, n_components=20, top_k=1, lyr_idx = 2):
|
|
170 |
for indx in range(2,12):
|
171 |
Image.fromarray(visualize_image(model,
|
172 |
"https://github.com/jacobgil/pytorch-grad-cam/blob/master/examples/both.png?raw=true", lyr_idx = indx))
|
|
|
|
82 |
return Image.fromarray(final_image), caption
|
83 |
|
84 |
|
85 |
+
"""
|
86 |
import yaml
|
87 |
import torch
|
88 |
import warnings
|
|
|
104 |
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True).to(device)
|
105 |
print(f"Loaded YOLOv5 model on {device}")
|
106 |
def create_labels(concept_scores, top_k=2):
|
107 |
+
|
108 |
yolov5_categories_url = \
|
109 |
"https://github.com/ultralytics/yolov5/raw/master/data/coco128.yaml" # URL to the YOLOv5 categories file
|
110 |
yaml_data = requests.get(yolov5_categories_url).text
|
|
|
123 |
return concept_labels_topk
|
124 |
|
125 |
def get_image_from_url(url, device):
|
126 |
+
|
|
|
|
|
127 |
|
128 |
img = np.array(Image.open(os.path.join(os.getcwd(), "data/xai/sample1.jpeg")))
|
129 |
img = cv2.resize(img, (640, 640))
|
|
|
168 |
for indx in range(2,12):
|
169 |
Image.fromarray(visualize_image(model,
|
170 |
"https://github.com/jacobgil/pytorch-grad-cam/blob/master/examples/both.png?raw=true", lyr_idx = indx))
|
171 |
+
"""
|