Spaces:
Build error
Build error
Commit ·
077796f
1
Parent(s): 9fcf801
computer vision 1
Browse files- app.py +36 -36
- requirements.txt +53 -45
app.py
CHANGED
|
@@ -50,42 +50,42 @@ interface_image = gr.Interface(
|
|
| 50 |
cache_examples=False,
|
| 51 |
)
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 50 |
cache_examples=False,
|
| 51 |
)
|
| 52 |
|
| 53 |
+
def show_preds_video(video_path):
|
| 54 |
+
cap = cv2.VideoCapture(video_path)
|
| 55 |
+
while(cap.isOpened()):
|
| 56 |
+
ret, frame = cap.read()
|
| 57 |
+
if ret:
|
| 58 |
+
frame_copy = frame.copy()
|
| 59 |
+
outputs = model.predict(source=frame)
|
| 60 |
+
results = outputs[0].cpu().numpy()
|
| 61 |
+
for i, det in enumerate(results.boxes.xyxy):
|
| 62 |
+
cv2.rectangle(
|
| 63 |
+
frame_copy,
|
| 64 |
+
(int(det[0]), int(det[1])),
|
| 65 |
+
(int(det[2]), int(det[3])),
|
| 66 |
+
color=(0, 0, 255),
|
| 67 |
+
thickness=2,
|
| 68 |
+
lineType=cv2.LINE_AA
|
| 69 |
+
)
|
| 70 |
+
yield cv2.cvtColor(frame_copy, cv2.COLOR_BGR2RGB)
|
| 71 |
|
| 72 |
+
inputs_video = [
|
| 73 |
+
gr.components.Video(type="filepath", label="Input Video"),
|
| 74 |
|
| 75 |
+
]
|
| 76 |
+
outputs_video = [
|
| 77 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
| 78 |
+
]
|
| 79 |
+
interface_video = gr.Interface(
|
| 80 |
+
fn=show_preds_video,
|
| 81 |
+
inputs=inputs_video,
|
| 82 |
+
outputs=outputs_video,
|
| 83 |
+
title="Pothole detector",
|
| 84 |
+
examples=video_path,
|
| 85 |
+
cache_examples=False,
|
| 86 |
+
)
|
| 87 |
|
| 88 |
+
gr.TabbedInterface(
|
| 89 |
+
[interface_image, interface_video],
|
| 90 |
+
tab_names=['Image inference', 'Video inference']
|
| 91 |
+
).queue().launch()
|
requirements.txt
CHANGED
|
@@ -1,47 +1,55 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
hydra-core>=1.2.0
|
| 6 |
-
matplotlib>=3.2.2
|
| 7 |
-
numpy>=1.18.5
|
| 8 |
-
opencv-python>=4.1.1
|
| 9 |
-
Pillow>=7.1.2
|
| 10 |
-
PyYAML>=5.3.1
|
| 11 |
-
requests>=2.23.0
|
| 12 |
-
scipy>=1.4.1
|
| 13 |
-
torch>=1.7.0
|
| 14 |
-
torchvision>=0.8.1
|
| 15 |
-
tqdm>=4.64.0
|
| 16 |
ultralytics
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
#
|
| 29 |
-
#
|
| 30 |
-
#
|
| 31 |
-
#
|
| 32 |
-
#
|
| 33 |
-
#
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
#
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
#
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
opencv-python
|
| 2 |
+
matplotlib
|
| 3 |
+
requests
|
| 4 |
+
hydra-core
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
ultralytics
|
| 6 |
+
gradio
|
| 7 |
|
| 8 |
+
|
| 9 |
+
# # Ultralytics requirements
|
| 10 |
+
# # Usage: pip install -r requirements.txt
|
| 11 |
+
|
| 12 |
+
# # Base ----------------------------------------
|
| 13 |
+
# hydra-core>=1.2.0
|
| 14 |
+
# matplotlib>=3.2.2
|
| 15 |
+
# numpy>=1.18.5
|
| 16 |
+
# opencv-python>=4.1.1
|
| 17 |
+
# Pillow>=7.1.2
|
| 18 |
+
# PyYAML>=5.3.1
|
| 19 |
+
# requests>=2.23.0
|
| 20 |
+
# scipy>=1.4.1
|
| 21 |
+
# torch>=1.7.0
|
| 22 |
+
# torchvision>=0.8.1
|
| 23 |
+
# tqdm>=4.64.0
|
| 24 |
+
# ultralytics
|
| 25 |
+
|
| 26 |
+
# # Logging -------------------------------------
|
| 27 |
+
# tensorboard>=2.4.1
|
| 28 |
+
# # clearml
|
| 29 |
+
# # comet
|
| 30 |
+
|
| 31 |
+
# # Plotting ------------------------------------
|
| 32 |
+
# pandas>=1.1.4
|
| 33 |
+
# seaborn>=0.11.0
|
| 34 |
+
|
| 35 |
+
# # Export --------------------------------------
|
| 36 |
+
# # coremltools>=6.0 # CoreML export
|
| 37 |
+
# # onnx>=1.12.0 # ONNX export
|
| 38 |
+
# # onnx-simplifier>=0.4.1 # ONNX simplifier
|
| 39 |
+
# # nvidia-pyindex # TensorRT export
|
| 40 |
+
# # nvidia-tensorrt # TensorRT export
|
| 41 |
+
# # scikit-learn==0.19.2 # CoreML quantization
|
| 42 |
+
# # tensorflow>=2.4.1 # TF exports (-cpu, -aarch64, -macos)
|
| 43 |
+
# # tensorflowjs>=3.9.0 # TF.js export
|
| 44 |
+
# # openvino-dev # OpenVINO export
|
| 45 |
+
|
| 46 |
+
# # Extras --------------------------------------
|
| 47 |
+
# ipython # interactive notebook
|
| 48 |
+
# psutil # system utilization
|
| 49 |
+
# thop>=0.1.1 # FLOPs computation
|
| 50 |
+
# # albumentations>=1.0.3
|
| 51 |
+
# # pycocotools>=2.0.6 # COCO mAP
|
| 52 |
+
# # roboflow
|
| 53 |
+
|
| 54 |
+
# # HUB -----------------------------------------
|
| 55 |
+
# GitPython>=3.1.24
|