Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -158,21 +158,22 @@ with gr.Blocks(css=custom_css) as interface:
|
|
| 158 |
if __name__ == "__main__":
|
| 159 |
interface.launch(share=True)
|
| 160 |
"""
|
|
|
|
| 161 |
import gradio as gr
|
| 162 |
import torch
|
| 163 |
from ultralytics import YOLO
|
| 164 |
import os
|
| 165 |
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
| 167 |
"""
|
| 168 |
Visualizes the given YOLOv5 model using Netron.
|
| 169 |
-
|
| 170 |
-
Args:
|
| 171 |
-
model_path: The path to the YOLOv5 model directory.
|
| 172 |
"""
|
| 173 |
try:
|
| 174 |
# Load the YOLOv5 model
|
| 175 |
-
model = YOLO(model_path)
|
| 176 |
|
| 177 |
# Extract the PyTorch model
|
| 178 |
pytorch_model = model.model
|
|
@@ -190,10 +191,10 @@ def visualize_yolov5(model_path):
|
|
| 190 |
# Create the Gradio interface
|
| 191 |
iface = gr.Interface(
|
| 192 |
fn=visualize_yolov5,
|
| 193 |
-
inputs=
|
| 194 |
outputs="text",
|
| 195 |
title="Netron YOLOv5 Model Visualization",
|
| 196 |
-
description="
|
| 197 |
)
|
| 198 |
|
| 199 |
# Launch the Gradio app
|
|
|
|
| 158 |
if __name__ == "__main__":
|
| 159 |
interface.launch(share=True)
|
| 160 |
"""
|
| 161 |
+
|
| 162 |
import gradio as gr
|
| 163 |
import torch
|
| 164 |
from ultralytics import YOLO
|
| 165 |
import os
|
| 166 |
|
| 167 |
+
# Assuming the YOLOv5 model is located in the same directory as this script
|
| 168 |
+
model_path = os.path.join(os.getcwd(), "weight_files/yolov5.onnx") # Replace with the actual model directory name
|
| 169 |
+
|
| 170 |
+
def visualize_yolov5():
|
| 171 |
"""
|
| 172 |
Visualizes the given YOLOv5 model using Netron.
|
|
|
|
|
|
|
|
|
|
| 173 |
"""
|
| 174 |
try:
|
| 175 |
# Load the YOLOv5 model
|
| 176 |
+
model = YOLO(model_path)
|
| 177 |
|
| 178 |
# Extract the PyTorch model
|
| 179 |
pytorch_model = model.model
|
|
|
|
| 191 |
# Create the Gradio interface
|
| 192 |
iface = gr.Interface(
|
| 193 |
fn=visualize_yolov5,
|
| 194 |
+
inputs=None, # No input required
|
| 195 |
outputs="text",
|
| 196 |
title="Netron YOLOv5 Model Visualization",
|
| 197 |
+
description="Visualize the YOLOv5 model."
|
| 198 |
)
|
| 199 |
|
| 200 |
# Launch the Gradio app
|