Spaces:
Running
on
Zero
Running
on
Zero
fix infinite image loading
Browse files- app.py +6 -7
- history.md +6 -0
app.py
CHANGED
@@ -245,12 +245,12 @@ def predict_depth(input_image):
|
|
245 |
|
246 |
print("Depth map created!")
|
247 |
print(f"Returning - output_path: {output_path}, focallength_px: {focallength_px}, raw_depth_path: {raw_depth_path}, temp_file: {temp_file}")
|
248 |
-
return output_path, f"Focal length: {focallength_px:.2f} pixels", raw_depth_path,
|
249 |
except Exception as e:
|
250 |
import traceback
|
251 |
error_message = f"An error occurred: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
252 |
print(error_message)
|
253 |
-
return None, error_message, None, None
|
254 |
finally:
|
255 |
if temp_file and os.path.exists(temp_file):
|
256 |
os.remove(temp_file)
|
@@ -324,24 +324,23 @@ with gr.Blocks() as iface:
|
|
324 |
model_status = gr.Textbox(label="3D Model Status")
|
325 |
|
326 |
# Hidden components to store intermediate results
|
327 |
-
hidden_image_path = gr.State("temp_input_image.png")
|
328 |
hidden_focal_length = gr.State()
|
329 |
|
330 |
input_image.change(
|
331 |
-
|
332 |
inputs=[input_image],
|
333 |
-
outputs=[
|
334 |
)
|
335 |
|
336 |
generate_3d_button.click(
|
337 |
create_3d_model,
|
338 |
-
inputs=[raw_depth_csv,
|
339 |
outputs=[view_3d_model, download_3d_model, model_status]
|
340 |
)
|
341 |
|
342 |
regenerate_button.click(
|
343 |
create_3d_model,
|
344 |
-
inputs=[raw_depth_csv,
|
345 |
outputs=[view_3d_model, download_3d_model, model_status]
|
346 |
)
|
347 |
|
|
|
245 |
|
246 |
print("Depth map created!")
|
247 |
print(f"Returning - output_path: {output_path}, focallength_px: {focallength_px}, raw_depth_path: {raw_depth_path}, temp_file: {temp_file}")
|
248 |
+
return output_path, f"Focal length: {focallength_px:.2f} pixels", raw_depth_path, focallength_px
|
249 |
except Exception as e:
|
250 |
import traceback
|
251 |
error_message = f"An error occurred: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
252 |
print(error_message)
|
253 |
+
return None, error_message, None, None
|
254 |
finally:
|
255 |
if temp_file and os.path.exists(temp_file):
|
256 |
os.remove(temp_file)
|
|
|
324 |
model_status = gr.Textbox(label="3D Model Status")
|
325 |
|
326 |
# Hidden components to store intermediate results
|
|
|
327 |
hidden_focal_length = gr.State()
|
328 |
|
329 |
input_image.change(
|
330 |
+
predict_depth,
|
331 |
inputs=[input_image],
|
332 |
+
outputs=[depth_map, focal_length, raw_depth_csv, hidden_focal_length]
|
333 |
)
|
334 |
|
335 |
generate_3d_button.click(
|
336 |
create_3d_model,
|
337 |
+
inputs=[raw_depth_csv, input_image, hidden_focal_length, simplification_factor, smoothing_iterations, thin_threshold],
|
338 |
outputs=[view_3d_model, download_3d_model, model_status]
|
339 |
)
|
340 |
|
341 |
regenerate_button.click(
|
342 |
create_3d_model,
|
343 |
+
inputs=[raw_depth_csv, input_image, hidden_focal_length, simplification_factor, smoothing_iterations, thin_threshold],
|
344 |
outputs=[view_3d_model, download_3d_model, model_status]
|
345 |
)
|
346 |
|
history.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1 |
# Change Log
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
## 2024-10-05 21:20 PST
|
4 |
### 3D Model Generation File Access Error
|
5 |
- Problem: When attempting to generate the 3D model, an error occurred: "[Errno 2] No such file or directory: '/tmp/tmppgls861k.png'"
|
|
|
1 |
# Change Log
|
2 |
|
3 |
+
## 2024-10-05 22:00 PST
|
4 |
+
### Infinite Image Reloading Issue
|
5 |
+
- Problem: After recent changes, dragging an image into the interface causes it to flicker and continuously reload. The depth prediction does not run.
|
6 |
+
- Suspected cause: Recent modifications to the input handling in the Gradio interface, particularly the `input_image.change` event.
|
7 |
+
- Next steps: Revert the changes to the input handling and investigate a different approach to manage the image path.
|
8 |
+
|
9 |
## 2024-10-05 21:20 PST
|
10 |
### 3D Model Generation File Access Error
|
11 |
- Problem: When attempting to generate the 3D model, an error occurred: "[Errno 2] No such file or directory: '/tmp/tmppgls861k.png'"
|