Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -190,27 +190,31 @@ def export_to_excel(room_numbers, meter_values):
|
|
| 190 |
except Exception as e:
|
| 191 |
return str(e)
|
| 192 |
|
| 193 |
-
#
|
| 194 |
-
def process_images(folder_path):
|
| 195 |
-
result = load_images_with_progress(folder_path)
|
| 196 |
-
if isinstance(result, str): # Error message
|
| 197 |
-
return result, None, None, None, None
|
| 198 |
-
return result
|
| 199 |
-
|
| 200 |
def update_room_number(room_number):
|
| 201 |
if annotations:
|
| 202 |
annotations[current_index]["room_number"] = room_number
|
| 203 |
return room_number
|
| 204 |
|
|
|
|
| 205 |
def update_meter_value(meter_value):
|
| 206 |
if annotations:
|
| 207 |
annotations[current_index]["meter_value"] = meter_value
|
| 208 |
return meter_value
|
| 209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
with gr.Blocks() as demo:
|
| 211 |
gr.Markdown("# Image Cropping Tool with Gradio")
|
| 212 |
|
| 213 |
-
folder_input = gr.
|
| 214 |
process_button = gr.Button("Process Images")
|
| 215 |
original_image_output = gr.Image(label="Original Image")
|
| 216 |
cropped_image_output = gr.Image(label="Cropped Image")
|
|
|
|
| 190 |
except Exception as e:
|
| 191 |
return str(e)
|
| 192 |
|
| 193 |
+
# Function to update room number
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
def update_room_number(room_number):
|
| 195 |
if annotations:
|
| 196 |
annotations[current_index]["room_number"] = room_number
|
| 197 |
return room_number
|
| 198 |
|
| 199 |
+
# Function to update meter value
|
| 200 |
def update_meter_value(meter_value):
|
| 201 |
if annotations:
|
| 202 |
annotations[current_index]["meter_value"] = meter_value
|
| 203 |
return meter_value
|
| 204 |
|
| 205 |
+
# Gradio Interface
|
| 206 |
+
def process_images(folder_path):
|
| 207 |
+
if isinstance(folder_path, dict):
|
| 208 |
+
folder_path = folder_path['name']
|
| 209 |
+
result = load_images_with_progress(folder_path)
|
| 210 |
+
if isinstance(result, str): # Error message
|
| 211 |
+
return result, None, None, None, None
|
| 212 |
+
return result
|
| 213 |
+
|
| 214 |
with gr.Blocks() as demo:
|
| 215 |
gr.Markdown("# Image Cropping Tool with Gradio")
|
| 216 |
|
| 217 |
+
folder_input = gr.File(label="Upload Folder of Images", file_count="directory")
|
| 218 |
process_button = gr.Button("Process Images")
|
| 219 |
original_image_output = gr.Image(label="Original Image")
|
| 220 |
cropped_image_output = gr.Image(label="Cropped Image")
|