Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| sys.path.append(os.getcwd()) | |
| from Lib.Const import COLOR_MAP, LABELS | |
| from Lib.BirdNestDetection import DetectNests | |
| import cv2 | |
| import gradio as gr | |
| demoImages = [ | |
| "data/150000 (3.07)_orj.jpg", | |
| "data/150021 (3.07)_orj.jpg", | |
| "data/150253 (3.07)_orj.jpg", | |
| "data/150261 (3.07)_orj.jpg" | |
| ] | |
| def Warning(): | |
| gr.Info("DGH ARGE YAZILIM DANIŞMANLIK ENERJİ İNŞAAT SAN.TİC.LTD.ŞTİ", duration=0.5) | |
| with gr.Blocks(css="footer{display:none !important}") as block: | |
| gr.Markdown("## Yüksek Gerilim Hatlarında Kuş Yuvası Tespiti - Demo") | |
| with gr.Row(): | |
| with gr.Column(): | |
| inputImage = gr.Image(label="Fotoğraf") | |
| with gr.Column(): | |
| thresholdSlider = gr.Slider(0, 1, value=0.25, label="Model Eşik Değeri", info="0 ve 1 arası seçiniz.") | |
| iouThresholdSlider = gr.Slider(0, 1, value=0.45, label="IOU (Intersection Over Union) Eşik Değeri", info="0 ve 1 arası seçiniz.") | |
| with gr.Accordion("Demo Görsellerden Seçebilirsiniz", open=False): | |
| imageGallery = gr.Examples( | |
| examples=[ | |
| os.path.join("data", img_name) for img_name in sorted(os.listdir("data")) | |
| ], | |
| inputs=[inputImage], | |
| label="Örnekler", | |
| cache_examples=False, | |
| examples_per_page=7 | |
| ) | |
| results = gr.Textbox(label="Durum") | |
| processButton = gr.Button("Tespit Et") | |
| gr.HTML("</hr>") | |
| processedImageGallery = gr.Gallery( | |
| label="Sonuçlar", | |
| rows=1, | |
| columns=2, | |
| object_fit="contain", | |
| height="auto" | |
| ) | |
| annotatedImage = gr.AnnotatedImage(color_map=COLOR_MAP) | |
| def Process(image, model_threshold, iouThresholdSlider): | |
| if image is None: | |
| raise gr.Warning("Lütfen görüntü yükleyiniz veya hazır seçiniz!", duration=3) | |
| image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) | |
| img0, boxes, labels = DetectNests(image, model_threshold, iouThresholdSlider) | |
| if len(boxes) == 0: | |
| raise gr.Error("Bir Hata ile Karşılaşıldı: Görüntüde Tespit Yapılamadı 💥!", duration=5) | |
| sections = [] | |
| for b, c in zip(boxes, labels): | |
| sections+=[(b, LABELS[c])] | |
| image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | |
| return [img0], (image, sections), "Görüntü İşlendi!" | |
| block.load(Warning) | |
| block.queue(max_size=10) | |
| block.launch(server_name="0.0.0.0", server_port=1071) | |