Ariel commited on
Commit
acd84a0
·
1 Parent(s): 55f9d1e

added comments

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -2,20 +2,30 @@ import gradio as gr
2
  import os
3
  from SolarPanelDetector import solar_panel_predict, detector
4
 
 
5
  custom_css = """
6
  .feedback textarea {font-size: 20px !important;}
7
  .centered-text {text-align: center; width: 100%;}
8
  .center-image {display: flex; justify-content: center; align-items: center;}
9
  """
 
10
  logo_url = 'https://raw.githubusercontent.com/ArielDrabkin/Solar-Panel-Detector/master/deployment/examples/DALL-E.jpeg'
11
 
 
12
  with gr.Blocks(theme="HaleyCH/HaleyCH_Theme", title="Solar Panel Detector", css=custom_css) as app:
 
13
  gr.Markdown("# **Solar Panel Detector 2.0** 🛰️☀️", elem_classes="centered-text")
 
 
14
  with gr.Row(elem_classes="center-image"):
15
  gr.Image(logo_url, scale=1, height=450, width=700, show_label=False, show_download_button=False,
16
  show_share_button=False)
17
- gr.Markdown("## This app provides the ability to detect solar panels in a given address or a given satellite image.")
18
 
 
 
 
 
 
19
  gr.Markdown("### Using by address with google maps:\n1. Enter an address or geographic coordinates.\n"
20
  "2. Insert your Google maps api key which you can get from - "
21
  "https://developers.google.com/maps/documentation/maps-static/get-api-key .\n"
@@ -25,20 +35,26 @@ with gr.Blocks(theme="HaleyCH/HaleyCH_Theme", title="Solar Panel Detector", css=
25
  zoom = gr.Slider(minimum=18, maximum=22, step=1, value=19, label="zoom")
26
  btn = gr.Button(value="Submit")
27
 
 
28
  with gr.Row():
29
  predicted_image_address = gr.Image(type="pil", show_label=False, scale=1)
30
  prediction_address = gr.Textbox(type="text", show_label=False, scale=1, elem_classes="feedback")
31
  btn.click(detector, inputs=[address, api_key, zoom], outputs=[predicted_image_address, prediction_address])
32
 
 
33
  gr.Markdown("### Using by a given image:\nUpload an image or use the examples below.")
34
  with gr.Row():
35
  im = gr.Image(type="pil", show_label=False, scale=1)
36
  predicted_image = gr.Image(type="pil", show_label=False, scale=1)
37
 
 
38
  prediction = gr.Textbox(type="text", show_label=False, elem_classes="feedback")
39
  btn = gr.Button(value="Submit")
 
 
40
  btn.click(solar_panel_predict, inputs=im, outputs=[predicted_image, prediction])
41
 
 
42
  gr.Markdown("### Image Examples")
43
  gr.Examples(
44
  examples=[os.path.join(os.path.dirname(__file__), "examples/Gottingen.jpg"),
 
2
  import os
3
  from SolarPanelDetector import solar_panel_predict, detector
4
 
5
+ # Custom CSS for styling the app
6
  custom_css = """
7
  .feedback textarea {font-size: 20px !important;}
8
  .centered-text {text-align: center; width: 100%;}
9
  .center-image {display: flex; justify-content: center; align-items: center;}
10
  """
11
+ # URL for the logo image
12
  logo_url = 'https://raw.githubusercontent.com/ArielDrabkin/Solar-Panel-Detector/master/deployment/examples/DALL-E.jpeg'
13
 
14
+ # Starting Gradio app configuration
15
  with gr.Blocks(theme="HaleyCH/HaleyCH_Theme", title="Solar Panel Detector", css=custom_css) as app:
16
+ # Main title for the app
17
  gr.Markdown("# **Solar Panel Detector 2.0** 🛰️☀️", elem_classes="centered-text")
18
+
19
+ # Displaying the logo
20
  with gr.Row(elem_classes="center-image"):
21
  gr.Image(logo_url, scale=1, height=450, width=700, show_label=False, show_download_button=False,
22
  show_share_button=False)
 
23
 
24
+ # Description for using the app with address and Google Maps API
25
+ gr.Markdown(
26
+ "## This app provides the ability to detect solar panels in a given address or a given satellite image.")
27
+
28
+ # Instructions for address-based detection
29
  gr.Markdown("### Using by address with google maps:\n1. Enter an address or geographic coordinates.\n"
30
  "2. Insert your Google maps api key which you can get from - "
31
  "https://developers.google.com/maps/documentation/maps-static/get-api-key .\n"
 
35
  zoom = gr.Slider(minimum=18, maximum=22, step=1, value=19, label="zoom")
36
  btn = gr.Button(value="Submit")
37
 
38
+ # Layout for displaying predictions for address-based detection
39
  with gr.Row():
40
  predicted_image_address = gr.Image(type="pil", show_label=False, scale=1)
41
  prediction_address = gr.Textbox(type="text", show_label=False, scale=1, elem_classes="feedback")
42
  btn.click(detector, inputs=[address, api_key, zoom], outputs=[predicted_image_address, prediction_address])
43
 
44
+ # Description for image-based detection
45
  gr.Markdown("### Using by a given image:\nUpload an image or use the examples below.")
46
  with gr.Row():
47
  im = gr.Image(type="pil", show_label=False, scale=1)
48
  predicted_image = gr.Image(type="pil", show_label=False, scale=1)
49
 
50
+ # Layout for displaying predictions for image-based detection
51
  prediction = gr.Textbox(type="text", show_label=False, elem_classes="feedback")
52
  btn = gr.Button(value="Submit")
53
+
54
+ # Function call for image-based detection
55
  btn.click(solar_panel_predict, inputs=im, outputs=[predicted_image, prediction])
56
 
57
+ # Providing example images for quick testing
58
  gr.Markdown("### Image Examples")
59
  gr.Examples(
60
  examples=[os.path.join(os.path.dirname(__file__), "examples/Gottingen.jpg"),