Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ from yolov5.models.experimental import attempt_load
|
|
18 |
from yolov5.utils.general import non_max_suppression
|
19 |
from yolov5.utils.augmentations import letterbox
|
20 |
|
21 |
-
|
22 |
# Example URLs for downloading images
|
23 |
file_urls = [
|
24 |
"https://www.dropbox.com/scl/fi/n3bs5xnl2kanqmwv483k3/1_jpg.rf.4a59a63d0a7339d280dd18ef3c2e675a.jpg?rlkey=4n9dnls1byb4wm54ycxzx3ovi&st=ue5xv8yx&dl=0",
|
@@ -40,7 +40,7 @@ def download_file(url, save_name):
|
|
40 |
# Download images
|
41 |
for i, url in enumerate(file_urls):
|
42 |
download_file(url, f"image_{i}.jpg")
|
43 |
-
|
44 |
|
45 |
# Load YOLOv5 model (placeholder)
|
46 |
model_path = "best.pt" # Path to your YOLOv5 model
|
@@ -113,7 +113,7 @@ def show_preds_image(filepath):
|
|
113 |
img0 = cv2.imread(filepath)
|
114 |
img_with_boxes = draw_bounding_boxes(img0, results)
|
115 |
return cv2.cvtColor(img_with_boxes, cv2.COLOR_BGR2RGB)
|
116 |
-
|
117 |
# Define Gradio components
|
118 |
input_component = gr.components.Image(type="filepath", label="Input Image")
|
119 |
output_component = gr.components.Image(type="numpy", label="Output Image")
|
@@ -163,6 +163,8 @@ def read_and_preprocess_dicom(file_path: str):
|
|
163 |
np.uint8)
|
164 |
image_pil = Image.fromarray(pixel_array)
|
165 |
#convert to cv2 format
|
|
|
|
|
166 |
image = np.array(image_pil)[::-1].copy()
|
167 |
|
168 |
# Collect metadata in dictionary format and convert to DataFrame
|
|
|
18 |
from yolov5.utils.general import non_max_suppression
|
19 |
from yolov5.utils.augmentations import letterbox
|
20 |
|
21 |
+
'''
|
22 |
# Example URLs for downloading images
|
23 |
file_urls = [
|
24 |
"https://www.dropbox.com/scl/fi/n3bs5xnl2kanqmwv483k3/1_jpg.rf.4a59a63d0a7339d280dd18ef3c2e675a.jpg?rlkey=4n9dnls1byb4wm54ycxzx3ovi&st=ue5xv8yx&dl=0",
|
|
|
40 |
# Download images
|
41 |
for i, url in enumerate(file_urls):
|
42 |
download_file(url, f"image_{i}.jpg")
|
43 |
+
'''
|
44 |
|
45 |
# Load YOLOv5 model (placeholder)
|
46 |
model_path = "best.pt" # Path to your YOLOv5 model
|
|
|
113 |
img0 = cv2.imread(filepath)
|
114 |
img_with_boxes = draw_bounding_boxes(img0, results)
|
115 |
return cv2.cvtColor(img_with_boxes, cv2.COLOR_BGR2RGB)
|
116 |
+
'''
|
117 |
# Define Gradio components
|
118 |
input_component = gr.components.Image(type="filepath", label="Input Image")
|
119 |
output_component = gr.components.Image(type="numpy", label="Output Image")
|
|
|
163 |
np.uint8)
|
164 |
image_pil = Image.fromarray(pixel_array)
|
165 |
#convert to cv2 format
|
166 |
+
image_pil = image_pil.reshape((image_pil.shape[0], image_pil.shape[1], 1))
|
167 |
+
print("In preprocess dicom:", image_pil.shape)
|
168 |
image = np.array(image_pil)[::-1].copy()
|
169 |
|
170 |
# Collect metadata in dictionary format and convert to DataFrame
|