oValach commited on
Commit
da8142e
1 Parent(s): 5a86498

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -3,8 +3,8 @@ import gradio as gr
3
  from TheDistanceAssessor import run, load_segformer, load_yolo
4
 
5
  def process_image(input_image):
6
- image_size = [1024,1024]
7
- target_distances = [650,1000,2000]
8
  num_ys = 10
9
 
10
  PATH_model_seg = 'SegFormer_B3_1024_finetuned.pth'
@@ -13,7 +13,7 @@ def process_image(input_image):
13
  model_det = load_yolo(PATH_model_det)
14
 
15
  input_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
16
- output_image = run(input_image, model_seg, model_det, image_size, target_distances, num_ys = num_ys)
17
  return output_image
18
 
19
  # Create the Gradio interface
@@ -22,9 +22,28 @@ iface = gr.Interface(
22
  inputs=gr.Image(type="numpy"), # Input type
23
  outputs=gr.Image(type="numpy"), # Output type
24
  title="RailSafeNet - Automatic Detection of Objects in the Track", # Title of the interface
25
- description="This is a demo of the master's thesis focused on the Automatic Detection of Objects in the Track.\n The repository with the code is accesible from: https://github.com/oValach/RailSafeNet_DT \n\nUpload an image with a scene including rail track and get a processed image with marked rail critical areas and detected and classified objects."
26
  )
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  # Launch the interface
29
  if __name__ == "__main__":
30
- iface.launch()
 
3
  from TheDistanceAssessor import run, load_segformer, load_yolo
4
 
5
  def process_image(input_image):
6
+ image_size = [1024, 1024]
7
+ target_distances = [650, 1000, 2000]
8
  num_ys = 10
9
 
10
  PATH_model_seg = 'SegFormer_B3_1024_finetuned.pth'
 
13
  model_det = load_yolo(PATH_model_det)
14
 
15
  input_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
16
+ output_image = run(input_image, model_seg, model_det, image_size, target_distances, num_ys=num_ys)
17
  return output_image
18
 
19
  # Create the Gradio interface
 
22
  inputs=gr.Image(type="numpy"), # Input type
23
  outputs=gr.Image(type="numpy"), # Output type
24
  title="RailSafeNet - Automatic Detection of Objects in the Track", # Title of the interface
25
+ description="This is a demo of the master's thesis focused on the Automatic Detection of Objects in the Track.\n The repository with the code is accessible from: https://github.com/oValach/RailSafeNet_DT \n\nUpload an image with a scene including rail track and get a processed image with marked rail critical areas and detected and classified objects."
26
  )
27
 
28
+ example_images = gr.Markdown(
29
+ """
30
+ ## Example input
31
+ Here are two example images that you can use:
32
+ """
33
+ )
34
+
35
+ example_image1 = gr.Image(value='rs00039.jpg', type='file', label="Example Image 1")
36
+ example_image2 = gr.Image(value='rs00042.jpg', type='file', label="Example Image 2")
37
+
38
+ # Combine the interface and example images
39
+ app = gr.Blocks()
40
+
41
+ with app:
42
+ iface.render()
43
+ example_images.render()
44
+ example_image1.render()
45
+ example_image2.render()
46
+
47
  # Launch the interface
48
  if __name__ == "__main__":
49
+ app.launch()