CineAI commited on
Commit
c0fce6a
·
verified ·
1 Parent(s): 66519d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -36
app.py CHANGED
@@ -1,36 +1,9 @@
1
  import gradio as gr
2
  import os
3
- # import subprocess
4
  import pandas as pd
5
  from PIL import Image
6
  import folium
7
 
8
- # --- Setup: Clone the repository for helper classes ---
9
- # This will only run once to fetch the necessary source code.
10
- # REPO_DIR = "TheAmateur"
11
- # if not os.path.exists(REPO_DIR):
12
- # try:
13
- # print(f"Cloning repository into ./{REPO_DIR}...")
14
- # subprocess.run(
15
- # ["git", "clone", "https://github.com/OrlovVladislav/TheAmateur.git"],
16
- # check=True,
17
- # capture_output=True,
18
- # text=True
19
- # )
20
- # print("Repository cloned successfully.")
21
- # except subprocess.CalledProcessError as e:
22
- # print(f"Error cloning repository: {e.stderr}")
23
- # exit() # Exit if cloning fails, as the app cannot run without it.
24
-
25
- # # Now that the repo is cloned, we can import the necessary modules
26
- # try:
27
- # from TheAmateur.src.rainbolt_parody import RainboltParody
28
- # from TheAmateur.src.map_gen import MapGenerator
29
- # from TheAmateur.src.geo_info import GeoInfo
30
- # except ImportError as e:
31
- # print(f"Failed to import from the cloned repository: {e}")
32
- # exit()
33
-
34
 
35
  from src.rainbolt_parody import RainboltParody
36
  from src.map_gen import MapGenerator
@@ -102,18 +75,20 @@ def pinpoint_location(api_key, uploaded_image):
102
  reasoning = response.get('reasoning', 'No reasoning provided.')
103
  coords_str = response.get('coordinates', '0,0')
104
 
105
- # --- FIX: Generate map HTML for the single point ---
106
  mgk = MapGenerator()
107
  single_point_map = mgk.get_map(location1=coords_str)
108
  map_html_output = single_point_map._repr_html_()
109
 
110
- ui_updates = {
111
- error_accordion: gr.Accordion(visible=True),
112
- save_accordion: gr.Accordion(visible=True)
113
- }
114
-
115
- # Return the map HTML instead of coordinates
116
- return info_df, reasoning, map_html_output, response, ui_updates
 
 
 
117
 
118
  except Exception as e:
119
  handle_error("Failed to process the image with the AI model", e)
@@ -211,7 +186,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="GeoGuessr AI") as app:
211
 
212
  with gr.Column(scale=2):
213
  gr.Markdown("### Map View")
214
- # --- FIX: Changed gr.Map to gr.HTML ---
215
  map_output_single = gr.HTML(label="Predicted Location")
216
  map_output_comparison = gr.HTML(visible=False)
217
 
 
1
  import gradio as gr
2
  import os
 
3
  import pandas as pd
4
  from PIL import Image
5
  import folium
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  from src.rainbolt_parody import RainboltParody
9
  from src.map_gen import MapGenerator
 
75
  reasoning = response.get('reasoning', 'No reasoning provided.')
76
  coords_str = response.get('coordinates', '0,0')
77
 
 
78
  mgk = MapGenerator()
79
  single_point_map = mgk.get_map(location1=coords_str)
80
  map_html_output = single_point_map._repr_html_()
81
 
82
+ # --- FIX IS HERE ---
83
+ # The return statement must have exactly 6 values to match the 6 outputs.
84
+ return (
85
+ info_df, # 1. for info_output_df
86
+ reasoning, # 2. for reasoning_output
87
+ map_html_output, # 3. for map_output_single
88
+ response, # 4. for prediction_state
89
+ gr.Accordion(visible=True), # 5. for error_accordion
90
+ gr.Accordion(visible=True) # 6. for save_accordion
91
+ )
92
 
93
  except Exception as e:
94
  handle_error("Failed to process the image with the AI model", e)
 
186
 
187
  with gr.Column(scale=2):
188
  gr.Markdown("### Map View")
 
189
  map_output_single = gr.HTML(label="Predicted Location")
190
  map_output_comparison = gr.HTML(visible=False)
191