Spaces:
Sleeping
Sleeping
run
Browse files
app.py
CHANGED
|
@@ -39,7 +39,6 @@
|
|
| 39 |
|
| 40 |
# if __name__ == "__main__":
|
| 41 |
# demo.launch()
|
| 42 |
-
|
| 43 |
import gradio as gr
|
| 44 |
import cv2
|
| 45 |
import numpy as np
|
|
@@ -49,6 +48,8 @@ import gc
|
|
| 49 |
from inspector_engine import AdvancedBlockInspector
|
| 50 |
|
| 51 |
# Initialize engine with lazy loading
|
|
|
|
|
|
|
| 52 |
inspector = AdvancedBlockInspector(yolo_model_path='yolo26n-obb.pt')
|
| 53 |
|
| 54 |
def inspect(image):
|
|
@@ -93,26 +94,29 @@ def inspect(image):
|
|
| 93 |
print(error_msg)
|
| 94 |
return None, {"error": str(e)}
|
| 95 |
|
| 96 |
-
# Create Gradio Interface
|
| 97 |
-
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 98 |
-
gr.Markdown("# TMTL Industrial Inspector")
|
| 99 |
-
gr.Markdown("Remote AI Inference Engine for Saddle Defect Detection")
|
| 100 |
|
| 101 |
with gr.Row():
|
| 102 |
-
with gr.Column():
|
| 103 |
input_img = gr.Image(type="numpy", label="Source Image")
|
| 104 |
-
btn = gr.Button("Run Analysis", variant="primary")
|
| 105 |
|
| 106 |
-
with gr.Column():
|
| 107 |
output_img = gr.Image(type="numpy", label="AI Visualization")
|
| 108 |
output_json = gr.JSON(label="Detailed Analysis")
|
| 109 |
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
btn.click(
|
| 112 |
fn=inspect,
|
| 113 |
inputs=input_img,
|
| 114 |
outputs=[output_img, output_json],
|
| 115 |
-
api_name="predict"
|
| 116 |
)
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
|
@@ -122,7 +126,5 @@ if __name__ == "__main__":
|
|
| 122 |
).launch(
|
| 123 |
server_name="0.0.0.0",
|
| 124 |
server_port=7860,
|
| 125 |
-
show_error=True
|
| 126 |
-
|
| 127 |
-
show_api=True
|
| 128 |
-
)
|
|
|
|
| 39 |
|
| 40 |
# if __name__ == "__main__":
|
| 41 |
# demo.launch()
|
|
|
|
| 42 |
import gradio as gr
|
| 43 |
import cv2
|
| 44 |
import numpy as np
|
|
|
|
| 48 |
from inspector_engine import AdvancedBlockInspector
|
| 49 |
|
| 50 |
# Initialize engine with lazy loading
|
| 51 |
+
# Note: HF Spaces will run this on startup.
|
| 52 |
+
# We use the local model file provided in the repository.
|
| 53 |
inspector = AdvancedBlockInspector(yolo_model_path='yolo26n-obb.pt')
|
| 54 |
|
| 55 |
def inspect(image):
|
|
|
|
| 94 |
print(error_msg)
|
| 95 |
return None, {"error": str(e)}
|
| 96 |
|
| 97 |
+
# Create Gradio Interface with a premium theme
|
| 98 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="indigo")) as demo:
|
| 99 |
+
gr.Markdown("# 🔍 TMTL Industrial Inspector")
|
| 100 |
+
gr.Markdown("### Remote AI Inference Engine for Saddle Defect Detection")
|
| 101 |
|
| 102 |
with gr.Row():
|
| 103 |
+
with gr.Column(scale=1):
|
| 104 |
input_img = gr.Image(type="numpy", label="Source Image")
|
| 105 |
+
btn = gr.Button("🚀 Run Analysis", variant="primary")
|
| 106 |
|
| 107 |
+
with gr.Column(scale=1):
|
| 108 |
output_img = gr.Image(type="numpy", label="AI Visualization")
|
| 109 |
output_json = gr.JSON(label="Detailed Analysis")
|
| 110 |
|
| 111 |
+
gr.Markdown("---")
|
| 112 |
+
gr.Markdown("© 2026 TMTL AI Solutions | Precision Inspection System")
|
| 113 |
+
|
| 114 |
+
# Wire up the button with API name
|
| 115 |
btn.click(
|
| 116 |
fn=inspect,
|
| 117 |
inputs=input_img,
|
| 118 |
outputs=[output_img, output_json],
|
| 119 |
+
api_name="predict"
|
| 120 |
)
|
| 121 |
|
| 122 |
if __name__ == "__main__":
|
|
|
|
| 126 |
).launch(
|
| 127 |
server_name="0.0.0.0",
|
| 128 |
server_port=7860,
|
| 129 |
+
show_error=True
|
| 130 |
+
)
|
|
|
|
|
|