blitzkrieg0000 commited on
Commit
f17256e
·
verified ·
1 Parent(s): 05afc14

Update UI/Main.py

Browse files
Files changed (1) hide show
  1. UI/Main.py +32 -32
UI/Main.py CHANGED
@@ -16,6 +16,11 @@ demoImages = [
16
  "data/DJI_20240905094647_0003_Z.JPG",
17
  "data/DJI_20240905101846_0005_W.JPG",
18
  "data/16_3450.png",
 
 
 
 
 
19
  ]
20
 
21
  MODEL = CablePoleSegmentation(retina_mask=False)
@@ -27,35 +32,38 @@ with gr.Blocks(css="footer{display:none !important}") as block:
27
  gr.Markdown("## Yüksek Gerilim Hattı Kablo ve Direk Tespit ve Segmentasyon Uygulaması - Demo")
28
 
29
  with gr.Row():
30
- image = gr.Image(label="Fotoğraf")
31
- processedImageGallery = gr.Gallery(
32
- label="Sonuçlar",
33
- rows=1,
34
- columns=2,
35
- object_fit="contain",
36
- height="auto"
37
- )
38
-
39
- with gr.Row() as imageGalleryRow:
40
- with gr.Accordion("Demo Görsellerden Seçebilirsiniz", open=False):
41
- imageGallery = gr.Gallery(
42
- demoImages,
43
- label="Demo Görseller",
44
- rows=2,
45
- columns=3,
46
- object_fit="contain",
47
- height="auto"
48
- )
49
-
50
 
51
  results = gr.Textbox(label="Log")
 
 
 
 
 
 
 
 
52
 
53
- thresholdSlider = gr.Slider(0, 1, value=0.5, label="Model Eşik Değeri", info="0 ve 1 arası seçiniz.")
54
-
55
- processButton = gr.Button("Tespit Et")
56
  annotatedImage = gr.AnnotatedImage(color_map=COLOR_MAP)
57
 
58
- @processButton.click(outputs=[processedImageGallery, annotatedImage, results], inputs=[image, thresholdSlider])
59
  def Process(image, model_threshold):
60
  if image is None:
61
  raise gr.Warning("Lütfen görüntü yükleyiniz veya hazır seçiniz!", duration=3)
@@ -78,12 +86,6 @@ with gr.Blocks(css="footer{display:none !important}") as block:
78
  return [image, canvas], (image, sections), "Görüntü İşlendi!"
79
 
80
 
81
- @imageGallery.select(inputs=imageGallery, outputs=[processedImageGallery, annotatedImage, results])
82
- def GalleryProcess(image, evt_data: gr.EventData):
83
- selectedIdx = evt_data._data["index"]
84
- imagePath = demoImages[selectedIdx]
85
- image = cv2.imread(imagePath)
86
- return Process(image, thresholdSlider.value)
87
 
88
 
89
  block.load(Warning)
@@ -91,5 +93,3 @@ with gr.Blocks(css="footer{display:none !important}") as block:
91
 
92
  block.queue(max_size=10)
93
  block.launch(server_name="0.0.0.0", server_port=1071)
94
-
95
-
 
16
  "data/DJI_20240905094647_0003_Z.JPG",
17
  "data/DJI_20240905101846_0005_W.JPG",
18
  "data/16_3450.png",
19
+ "data/16_3735.png",
20
+ "data/16_3900.png",
21
+ "data/19_00350.png",
22
+ "data/25_00272.png",
23
+ "data/67_02661.png"
24
  ]
25
 
26
  MODEL = CablePoleSegmentation(retina_mask=False)
 
32
  gr.Markdown("## Yüksek Gerilim Hattı Kablo ve Direk Tespit ve Segmentasyon Uygulaması - Demo")
33
 
34
  with gr.Row():
35
+
36
+ with gr.Column():
37
+ inputImage = gr.Image(label="Fotoğraf")
38
+ with gr.Accordion("Demo Görsellerden Seçebilirsiniz", open=False):
39
+ imageGallery = gr.Examples(
40
+ examples=[
41
+ os.path.join("data", img_name) for img_name in sorted(os.listdir("data"))
42
+ ],
43
+ inputs=[inputImage],
44
+ label="Örnekler",
45
+ cache_examples=False,
46
+ examples_per_page=5
47
+ )
48
+
49
+ with gr.Column():
50
+ thresholdSlider = gr.Slider(0, 1, value=0.5, label="Model Eşik Değeri", info="0 ve 1 arası seçiniz.")
51
+
52
+ processButton = gr.Button("Tespit Et")
 
 
53
 
54
  results = gr.Textbox(label="Log")
55
+ gr.HTML("</hr>")
56
+ processedImageGallery = gr.Gallery(
57
+ label="Sonuçlar",
58
+ rows=1,
59
+ columns=2,
60
+ object_fit="contain",
61
+ height="auto"
62
+ )
63
 
 
 
 
64
  annotatedImage = gr.AnnotatedImage(color_map=COLOR_MAP)
65
 
66
+ @processButton.click(outputs=[processedImageGallery, annotatedImage, results], inputs=[inputImage, thresholdSlider])
67
  def Process(image, model_threshold):
68
  if image is None:
69
  raise gr.Warning("Lütfen görüntü yükleyiniz veya hazır seçiniz!", duration=3)
 
86
  return [image, canvas], (image, sections), "Görüntü İşlendi!"
87
 
88
 
 
 
 
 
 
 
89
 
90
 
91
  block.load(Warning)
 
93
 
94
  block.queue(max_size=10)
95
  block.launch(server_name="0.0.0.0", server_port=1071)