Shared-Reality-Lab / IMAGE-server

IMAGE project server components
Other
2 stars 7 forks source link

Depth map errors out and returns bad JSON on specific photo #854

Closed jeffbl closed 2 months ago

jeffbl commented 2 months ago

Hat tip @jaydeepsingh25 for finding this

Current test extension, unicorn as backend

Go to this photo:

https://image.a11y.mcgill.ca/pages/imgs/queen-west-toronto.png

Get IMAGE rendering, and watch logs. Note:

object-depth-calculator-1         | 2024-07-18T15:24:33.077275172Z DEBUG:root:passed depth-map check                                                                                          
object-depth-calculator-1         | 2024-07-18T15:24:33.077305018Z DEBUG:root:passed objects check                                                                                            
object-depth-calculator-1         | 2024-07-18T15:24:33.082545159Z DEBUG:root:number of objects                                                                                             
object-depth-calculator-1         | 2024-07-18T15:24:33.083511643Z ERROR:object-depth-calculator:Exception on /preprocessor [POST]                                                            
object-depth-calculator-1         | 2024-07-18T15:24:33.083529847Z Traceback (most recent call last):                                                                                         
object-depth-calculator-1         | 2024-07-18T15:24:33.083536509Z   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2529, in wsgi_app                                      
object-depth-calculator-1         | 2024-07-18T15:24:33.083559131Z     response = self.full_dispatch_request()                                                                                
object-depth-calculator-1         | 2024-07-18T15:24:33.083565002Z   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request                         
object-depth-calculator-1         | 2024-07-18T15:24:33.083570913Z     rv = self.handle_user_exception(e)                                                                                     
object-depth-calculator-1         | 2024-07-18T15:24:33.083578077Z   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request                         
object-depth-calculator-1         | 2024-07-18T15:24:33.083585541Z     rv = self.dispatch_request()                                                                                           
object-depth-calculator-1         | 2024-07-18T15:24:33.083591943Z   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request                              
object-depth-calculator-1         | 2024-07-18T15:24:33.083597723Z     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)                                               
object-depth-calculator-1         | 2024-07-18T15:24:33.083603434Z   File "/app/object-depth-calculator.py", line 143, in objectdepth                                                         
object-depth-calculator-1         | 2024-07-18T15:24:33.083609135Z     validator.validate(obj_depth_output)                                                                                   
object-depth-calculator-1         | 2024-07-18T15:24:33.083614795Z UnboundLocalError: local variable 'obj_depth_output' referenced before assignment                      

then later, orchestrator complains about bad JSON

orchestrator-1                    | 2024-07-18T15:24:34.397228785Z Error occured on fetch from http://object-depth-calculator:5000/preprocessor                                               
orchestrator-1                    | 2024-07-18T15:24:34.398385364Z FetchError: invalid json response body at http://object-depth-calculator:5000/preprocessor reason: Unexpected token '<', "<
!doctype "... is not valid JSON                                                                                                                                                               
orchestrator-1                    | 2024-07-18T15:24:34.398402266Z     at /usr/src/app/node_modules/node-fetch/lib/index.js:273:32
orchestrator-1                    | 2024-07-18T15:24:34.398408878Z     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
orchestrator-1                    | 2024-07-18T15:24:34.398414759Z   type: 'invalid-json'
orchestrator-1                    | 2024-07-18T15:24:34.398420359Z }
orchestrator-1                    | 2024-07-18T15:24:34.398460023Z Now on priority group 5
jeffbl commented 2 months ago

@emmanuelwilson says: It looks to me that it breaks when there are no objects detected in the scene. As it looks to assign depth values to objects, if there are no objects then it breaks the JSON. A simple fix is to avoid populating the JSON if there are no objects present. I think if we just put those statements in the "if objects > 0" block I think that could fix it?

emmanuelwilson commented 2 months ago

Yes! Specifically for the "object-depth-calculator" preprocessor.