Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from itertools import islice
|
|
8 |
|
9 |
# Configuration
|
10 |
chunk_size = 100 # Size of the chunks to shuffle
|
11 |
-
label_file = "labels.csv"
|
12 |
|
13 |
# Load the Satellogic dataset (streaming)
|
14 |
dataset = ev.load_dataset("satellogic", streaming=True)
|
@@ -57,7 +57,7 @@ def get_next_image():
|
|
57 |
shuffled_chunk = []
|
58 |
chunk_iter = None
|
59 |
|
60 |
-
def rate_image(image_id, bounds, rating
|
61 |
global labels_df
|
62 |
|
63 |
new_row = pd.DataFrame(
|
@@ -65,7 +65,7 @@ def rate_image(image_id, bounds, rating, google_maps_link):
|
|
65 |
"image_id": [image_id],
|
66 |
"bounds": [bounds],
|
67 |
"rating": [rating],
|
68 |
-
"google_maps_link": [
|
69 |
}
|
70 |
)
|
71 |
labels_df = pd.concat([labels_df, new_row], ignore_index=True)
|
@@ -74,28 +74,26 @@ def rate_image(image_id, bounds, rating, google_maps_link):
|
|
74 |
next_image, next_image_id, next_bounds, next_google_maps_link = get_next_image()
|
75 |
return next_image, next_image_id, next_bounds, next_google_maps_link
|
76 |
|
77 |
-
# Gradio interface
|
78 |
iface = gr.Interface(
|
79 |
fn=rate_image,
|
80 |
inputs=[
|
81 |
gr.Textbox(label="Image ID", visible=False),
|
82 |
gr.Textbox(label="Bounds", visible=False),
|
83 |
gr.Radio(["Cool", "Not Cool"], label="Rating"),
|
84 |
-
gr.Textbox(label="Google Maps Link"),
|
85 |
],
|
86 |
outputs=[
|
87 |
gr.Image(label="Satellite Image"),
|
88 |
gr.Textbox(label="Image ID", visible=False),
|
89 |
gr.Textbox(label="Bounds", visible=False),
|
90 |
-
gr.Textbox(label="Google Maps Link"),
|
91 |
],
|
92 |
title="TerraNomaly - Satellite Image Labeling",
|
93 |
description="Rate satellite images as 'Cool' or 'Not Cool'.",
|
94 |
live=False,
|
95 |
)
|
96 |
|
97 |
-
# initial_image, initial_image_id, initial_bounds, initial_google_maps_link = get_next_image() # You don't need to call this here
|
98 |
-
|
99 |
iface.launch(
|
100 |
-
share=True
|
101 |
)
|
|
|
8 |
|
9 |
# Configuration
|
10 |
chunk_size = 100 # Size of the chunks to shuffle
|
11 |
+
label_file = os.path.join(os.path.dirname(__file__), "labels.csv") # Save CSV in the same directory as the script
|
12 |
|
13 |
# Load the Satellogic dataset (streaming)
|
14 |
dataset = ev.load_dataset("satellogic", streaming=True)
|
|
|
57 |
shuffled_chunk = []
|
58 |
chunk_iter = None
|
59 |
|
60 |
+
def rate_image(image_id, bounds, rating):
|
61 |
global labels_df
|
62 |
|
63 |
new_row = pd.DataFrame(
|
|
|
65 |
"image_id": [image_id],
|
66 |
"bounds": [bounds],
|
67 |
"rating": [rating],
|
68 |
+
"google_maps_link": [""], # this isn't necessary to pass to the function since we aren't updating it here.
|
69 |
}
|
70 |
)
|
71 |
labels_df = pd.concat([labels_df, new_row], ignore_index=True)
|
|
|
74 |
next_image, next_image_id, next_bounds, next_google_maps_link = get_next_image()
|
75 |
return next_image, next_image_id, next_bounds, next_google_maps_link
|
76 |
|
77 |
+
# Gradio interface
|
78 |
iface = gr.Interface(
|
79 |
fn=rate_image,
|
80 |
inputs=[
|
81 |
gr.Textbox(label="Image ID", visible=False),
|
82 |
gr.Textbox(label="Bounds", visible=False),
|
83 |
gr.Radio(["Cool", "Not Cool"], label="Rating"),
|
84 |
+
#gr.Textbox(label="Google Maps Link"), # Remove google maps link as an input
|
85 |
],
|
86 |
outputs=[
|
87 |
gr.Image(label="Satellite Image"),
|
88 |
gr.Textbox(label="Image ID", visible=False),
|
89 |
gr.Textbox(label="Bounds", visible=False),
|
90 |
+
gr.Textbox(label="Google Maps Link", visible=True), # Add google maps link as an output
|
91 |
],
|
92 |
title="TerraNomaly - Satellite Image Labeling",
|
93 |
description="Rate satellite images as 'Cool' or 'Not Cool'.",
|
94 |
live=False,
|
95 |
)
|
96 |
|
|
|
|
|
97 |
iface.launch(
|
98 |
+
share=True
|
99 |
)
|