fidler-lab / polyrnn-pp-pytorch

PyTorch training/tool code for Polygon-RNN++ (CVPR 2018)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception error after choosing a object in image

radeonwu opened this issue · comments

I fully followed the guidelines; after running both backend and frontend codes, the web page(localhost:8000) is brought up correctly. But once I click and choose a vehicle object in the default road image, the progress bar keeps updating but hang there for ever.

The detailed traces are copied below.
127.0.0.1 - - [23/Aug/2018 19:30:16] "OPTIONS /api/annotation_and_ggnn HTTP/1.1" 200 -
[2018-08-23 19:30:16,432] ERROR in app: Exception on /api/annotation_and_ggnn [POST]
Traceback (most recent call last):
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "Tool/tool.py", line 151, in generate_annotation_and_ggnn
instance = tool.data_loader.prepare_component(instance, component)
File "/home/xiaojun/data/polyrnn-pp-pytorch/code/DataProvider/cityscapes.py", line 166, in prepare_component
crop_info = self.extract_crop(component, instance, context_expansion)
File "/home/xiaojun/data/polyrnn-pp-pytorch/code/DataProvider/cityscapes.py", line 245, in extract_crop
img = utils.rgb_img_read(instance['img_path'])
File "/home/xiaojun/data/polyrnn-pp-pytorch/code/Utils/utils.py", line 55, in rgb_img_read
img = imread(img_path)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/skimage/io/_io.py", line 62, in imread
img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/skimage/io/manage_plugins.py", line 214, in call_plugin
return func(*args, **kwargs)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/skimage/io/_plugins/pil_plugin.py", line 35, in imread
with open(fname, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/ais/gobi6/amlan/poly_rnn_demo_images/city1.png'
127.0.0.1 - - [23/Aug/2018 19:30:16] "POST /api/annotation_and_ggnn HTTP/1.1" 500 -

Hi, it seems like you did not follow step 1 for the frontend. You need to go to polygon.js and change a variable to make it work on your machine.

Thanks for your reply.
I further modified globalFolder to the real value inside the polygon.js file, but the error still remains the same.
Even more weird, after a reboot, the localhost:8000 page then becomes the following,
"Directory listing for /"
......

Anything I missed?

If localhost:8000 shows a directory listing, then the server was not run at the right location. You need to run the http server inside the frontend.

globalFolder needs to point to <your_downloaded_code_directory>/Tool/frontend/static/img/

If you use any other folder, then you will need to copy the default images into that folder. Basically the server looks for files in that directory and if the required images are not there, it won't work. If you upload images to the Tool, then it also saves images in this directory.

Does this help?

I double checked the globalFolder has changed to the actual static/img/ folder, but the localhost:8000 still shows directory list.
Anyway in the directory list, I can still locate the frontend folder which brings up the labelling tool page.

After choosing a vehicle rectangle in the sample image, the error is now as below,

127.0.0.1 - - [27/Aug/2018 10:27:34] "OPTIONS /api/annotation_and_ggnn HTTP/1.1" 200 -
/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/skimage/transform/_warps.py:105: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "
/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/skimage/transform/_warps.py:110: UserWarning: Anti-aliasing will be enabled by default in skimage 0.15 to avoid aliasing artifacts when down-sampling images.
warn("Anti-aliasing will be enabled by default in skimage 0.15 to "
/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/torch/nn/functional.py:1749: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode))
tensor([ 0.6787, 0.6530, 0.6628, -inf, 0.6560], device='cuda:0')
[2018-08-27 10:27:34,907] ERROR in app: Exception on /api/annotation_and_ggnn [POST]
Traceback (most recent call last):
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "Tool/tool.py", line 152, in generate_annotation_and_ggnn
pred_annotation = tool.annotation(instance, run_ggnn=True)
File "Tool/tool.py", line 66, in annotation
run_ggnn=run_ggnn
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/xiaojun/data/polyrnn-pp-pytorch/code/Models/Poly/polyrnnpp.py", line 229, in forward
out_dict = self.ggnn(x, pred_polys, mode=self.mode, gt_polys=orig_poly, resnet_feature=resnet_feature)
File "/home/xiaojun/tfenv_xj/venv/lib/python3.5/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/xiaojun/data/polyrnn-pp-pytorch/code/Models/GGNN/poly_ggnn.py", line 223, in forward
self.max_poly_len)
File "/home/xiaojun/data/polyrnn-pp-pytorch/code/Utils/utils.py", line 217, in prepare_ggnn_component
for idx in xrange(len(enhanced_poly)):
NameError: name 'xrange' is not defined
127.0.0.1 - - [27/Aug/2018 10:27:34] "POST /api/annotation_and_ggnn HTTP/1.1" 500 -

hi,
Yes I am running Python 3.
After switching to Python 2.7, the labeling seems working properly.

Now a new question, below is the json file content created by the tool after I labelled 3 different objects. If you notice at the last portion, the 3 object labels are packed in the same field, thus we could not identify which vertexes belong to which object. And the 'bbox' field is not necessary for training purpose, possible to remove? thanks
{"poly":[[[260,234],[259,230],[264,238],[262,284],[268,344],[281,344],[285,331],[357,329],[374,320],[387,342],[387,329],[424,333],[420,255],[433,255],[426,232],[416,223],[396,203],[379,193],[377,206],[329,193],[292,186],[283,193],[268,217],[253,243]],[[668,82],[670,89],[672,108],[668,117],[664,157],[684,146],[691,133],[691,127],[698,127],[703,146],[713,136],[713,114],[713,106],[713,106],[719,101],[725,81],[665,78]],[[96,76],[118,70],[101,74],[92,80],[48,95],[60,112],[43,118],[35,129],[35,131],[35,157],[33,171],[58,154],[56,182],[94,190],[88,140],[94,125],[128,93],[96,83],[105,51],[173,61],[158,38],[139,63]]],"bbox":[[247.0565612724226,189.52284152405022,180.72356673900504,159.74068071312806],[657.2381397137599,69.7173309892042,152.97200780155484,98.14575721781172],[96.79202263549708,25.720957063978247,24.3672224816636,205.09078922066865]],"labels":["Car","Traffic Sign","Lamp Post"]}

I tried modifying the part for jason creation inside the polygon.js file, yet it turns out changes made inside this file does not take any effect in the created json file content.
Is polygon.js the right place?

update: the issue in previous thread is actually caused by Chrome browser. After using Chromium instead, with certain changes to the .js file, now I can generate jason file similar to the format that Cityscape script requires. Cheers!

One more finding when using the labeling tool: when "use fine polygon" is disabled, the auto generated polygon matches the actual object much better, compared to the result when "use fine polygon" is enabled.

Great! Glad that it works.

Your observation about the use fine polygon is contrary to what we have observed (both quantitatively and qualitatively) -- maybe it's a specific image?

I can confirm on the online labelling page, the result is better when "fine polygon" is enabled, as you said; but on my local version, it is contrary...
Am wondering whether it's due to the model i loaded. Below is the Frontend command I used,

python Tool/tool.py --exp Experiments/tool.json --reload /home/wu/data/polyrnn-pp-pytorch/models/evaluator_epoch19_step56000.pth --image_dir /home/wu/data/polyn-pp-pytorch/code/Tool/frontend/static/img/

where the model loaded is from the models folder. Is it correct?

I'm sorry, I looked at your command again. It seems you reloaded the evaluator model -- this model does not include the ggnn (use fine polygon option uses that). You should use the model that says ggnn.

I'm sorry, I looked at your command again. It seems you reloaded the evaluator model -- this model does not include the ggnn (use fine polygon option uses that). You should use the model that says ggnn.

I have seen two models: ggnn_epoch5_step14000 and ggnn_epoch8_step21000. Which one should I use? The later one shows error that the model architecture doesn't fit with the code.