mseg-dataset / mseg-semantic

An Official Repo of CVPR '20 "MSeg: A Composite Dataset for Multi-Domain Segmentation"
MIT License
457 stars 78 forks source link

problem with running the demo ( No module named 'apex' , No such file img3_overlaid_classes.jpg) #29

Closed EmanuelNk closed 2 years ago

EmanuelNk commented 3 years ago

I am trying to run the demo by following the instructions, but got an error saying " No module named 'apex' " (full output below"). which was followed by the error "No such file img3_overlaid_classes.jpg" in the next cell. I also tried downgrading pytorch to match the apex cuda version, as well as commenting out the bare metal version check in the setup.py. but nothing seemed to be working.

Namespace(config='mseg-semantic/mseg_semantic/config/test/default_config_360.yaml', file_save='default', opts=['model_name', 'mseg-3m', 'model_path', '/mseg-3m.pth', 'input_file', '/kitchen1.jpg']) arch: hrnet base_size: 360 batch_size_val: 1 dataset: kitchen1 has_prediction: False ignore_label: 255 img_name_unique: False index_start: 0 index_step: 0 input_file: /kitchen1.jpg layers: 50 model_name: mseg-3m model_path: /mseg-3m.pth network_name: None save_folder: default scales: [0.5, 0.75, 1.0, 1.25, 1.5, 1.75] small: True split: val test_gpu: [0] test_h: 713 test_w: 713 version: 4.0 vis_freq: 20 workers: 16 zoom_factor: 8 [2021-07-06 12:22:03,683 INFO universal_demo.py line 59 71646] arch: hrnet base_size: 360 batch_size_val: 1 dataset: kitchen1 has_prediction: False ignore_label: 255 img_name_unique: True index_start: 0 index_step: 0 input_file: /kitchen1.jpg layers: 50 model_name: mseg-3m model_path: /mseg-3m.pth network_name: None print_freq: 10 save_folder: default scales: [0.5, 0.75, 1.0, 1.25, 1.5, 1.75] small: True split: test test_gpu: [0] test_h: 713 test_w: 713 u_classes: ['backpack', 'umbrella', 'bag', 'tie', 'suitcase', 'case', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'animal_other', 'microwave', 'radiator', 'oven', 'toaster', 'storage_tank', 'conveyor_belt', 'sink', 'refrigerator', 'washer_dryer', 'fan', 'dishwasher', 'toilet', 'bathtub', 'shower', 'tunnel', 'bridge', 'pier_wharf', 'tent', 'building', 'ceiling', 'laptop', 'keyboard', 'mouse', 'remote', 'cell phone', 'television', 'floor', 'stage', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'fruit_other', 'food_other', 'chair_other', 'armchair', 'swivel_chair', 'stool', 'seat', 'couch', 'trash_can', 'potted_plant', 'nightstand', 'bed', 'table', 'pool_table', 'barrel', 'desk', 'ottoman', 'wardrobe', 'crib', 'basket', 'chest_of_drawers', 'bookshelf', 'counter_other', 'bathroom_counter', 'kitchen_island', 'door', 'light_other', 'lamp', 'sconce', 'chandelier', 'mirror', 'whiteboard', 'shelf', 'stairs', 'escalator', 'cabinet', 'fireplace', 'stove', 'arcade_machine', 'gravel', 'platform', 'playingfield', 'railroad', 'road', 'snow', 'sidewalk_pavement', 'runway', 'terrain', 'book', 'box', 'clock', 'vase', 'scissors', 'plaything_other', 'teddy_bear', 'hair_dryer', 'toothbrush', 'painting', 'poster', 'bulletin_board', 'bottle', 'cup', 'wine_glass', 'knife', 'fork', 'spoon', 'bowl', 'tray', 'range_hood', 'plate', 'person', 'rider_other', 'bicyclist', 'motorcyclist', 'paper', 'streetlight', 'road_barrier', 'mailbox', 'cctv_camera', 'junction_box', 'traffic_sign', 'traffic_light', 'fire_hydrant', 'parking_meter', 'bench', 'bike_rack', 'billboard', 'sky', 'pole', 'fence', 'railing_banister', 'guard_rail', 'mountain_hill', 'rock', 'frisbee', 'skis', 'snowboard', 'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard', 'surfboard', 'tennis_racket', 'net', 'base', 'sculpture', 'column', 'fountain', 'awning', 'apparel', 'banner', 'flag', 'blanket', 'curtain_other', 'shower_curtain', 'pillow', 'towel', 'rug_floormat', 'vegetation', 'bicycle', 'car', 'autorickshaw', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'trailer', 'boat_ship', 'slow_wheeled_object', 'river_lake', 'sea', 'water_other', 'swimming_pool', 'waterfall', 'wall', 'window', 'window_blind'] version: 4.0 vis_freq: 20 workers: 16 zoom_factor: 8 [2021-07-06 12:22:03,683 INFO universal_demo.py line 60 71646] => creating model ... Traceback (most recent call last): File "mseg-semantic/mseg_semantic/tool/universal_demo.py", line 105, in test_runner = UniversalDemoRunner(args, use_gpu) File "mseg-semantic/mseg_semantic/tool/universal_demo.py", line 70, in init scales = args.scales File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/emanuelml/code/Users/emanuel/mseg-semantic/mseg_semantic/tool/inference_task.py", line 219, in init self.model = self.load_model(args) File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/emanuelml/code/Users/emanuel/mseg-semantic/mseg_semantic/tool/inference_task.py", line 264, in load_model from mseg_semantic.model.seg_hrnet import get_configured_hrnet File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/emanuelml/code/Users/emanuel/mseg-semantic/mseg_semantic/model/seg_hrnet.py", line 17, in import apex ModuleNotFoundError: No module named 'apex'

thank you.

EmanuelNk commented 3 years ago

I also tried running the colab demo as is and got the following error message:

Namespace(config='mseg-semantic/mseg_semantic/config/test/default_config_360.yaml', file_save='default', opts=['model_name', 'mseg-3m', 'model_path', '/content/mseg-3m.pth', 'input_file', '/content/img3.jpg']) arch: hrnet base_size: 360 batch_size_val: 1 dataset: img3 has_prediction: False ignore_label: 255 img_name_unique: False index_start: 0 index_step: 0 input_file: /content/img3.jpg layers: 50 model_name: mseg-3m model_path: /content/mseg-3m.pth network_name: None save_folder: default scales: [0.5, 0.75, 1.0, 1.25, 1.5, 1.75] small: True split: val test_gpu: [0] test_h: 713 test_w: 713 version: 4.0 vis_freq: 20 workers: 16 zoom_factor: 8 [2021-07-06 12:43:09,452 INFO universal_demo.py line 59 359] arch: hrnet base_size: 360 batch_size_val: 1 dataset: img3 has_prediction: False ignore_label: 255 img_name_unique: True index_start: 0 index_step: 0 input_file: /content/img3.jpg layers: 50 model_name: mseg-3m model_path: /content/mseg-3m.pth network_name: None print_freq: 10 save_folder: default scales: [0.5, 0.75, 1.0, 1.25, 1.5, 1.75] small: True split: test test_gpu: [0] test_h: 713 test_w: 713 u_classes: ['backpack', 'umbrella', 'bag', 'tie', 'suitcase', 'case', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'animal_other', 'microwave', 'radiator', 'oven', 'toaster', 'storage_tank', 'conveyor_belt', 'sink', 'refrigerator', 'washer_dryer', 'fan', 'dishwasher', 'toilet', 'bathtub', 'shower', 'tunnel', 'bridge', 'pier_wharf', 'tent', 'building', 'ceiling', 'laptop', 'keyboard', 'mouse', 'remote', 'cell phone', 'television', 'floor', 'stage', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'fruit_other', 'food_other', 'chair_other', 'armchair', 'swivel_chair', 'stool', 'seat', 'couch', 'trash_can', 'potted_plant', 'nightstand', 'bed', 'table', 'pool_table', 'barrel', 'desk', 'ottoman', 'wardrobe', 'crib', 'basket', 'chest_of_drawers', 'bookshelf', 'counter_other', 'bathroom_counter', 'kitchen_island', 'door', 'light_other', 'lamp', 'sconce', 'chandelier', 'mirror', 'whiteboard', 'shelf', 'stairs', 'escalator', 'cabinet', 'fireplace', 'stove', 'arcade_machine', 'gravel', 'platform', 'playingfield', 'railroad', 'road', 'snow', 'sidewalk_pavement', 'runway', 'terrain', 'book', 'box', 'clock', 'vase', 'scissors', 'plaything_other', 'teddy_bear', 'hair_dryer', 'toothbrush', 'painting', 'poster', 'bulletin_board', 'bottle', 'cup', 'wine_glass', 'knife', 'fork', 'spoon', 'bowl', 'tray', 'range_hood', 'plate', 'person', 'rider_other', 'bicyclist', 'motorcyclist', 'paper', 'streetlight', 'road_barrier', 'mailbox', 'cctv_camera', 'junction_box', 'traffic_sign', 'traffic_light', 'fire_hydrant', 'parking_meter', 'bench', 'bike_rack', 'billboard', 'sky', 'pole', 'fence', 'railing_banister', 'guard_rail', 'mountain_hill', 'rock', 'frisbee', 'skis', 'snowboard', 'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard', 'surfboard', 'tennis_racket', 'net', 'base', 'sculpture', 'column', 'fountain', 'awning', 'apparel', 'banner', 'flag', 'blanket', 'curtain_other', 'shower_curtain', 'pillow', 'towel', 'rug_floormat', 'vegetation', 'bicycle', 'car', 'autorickshaw', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'trailer', 'boat_ship', 'slow_wheeled_object', 'river_lake', 'sea', 'water_other', 'swimming_pool', 'waterfall', 'wall', 'window', 'window_blind'] version: 4.0 vis_freq: 20 workers: 16 zoom_factor: 8 [2021-07-06 12:43:09,453 INFO universal_demo.py line 60 359] => creating model ... Traceback (most recent call last): File "mseg-semantic/mseg_semantic/tool/universal_demo.py", line 105, in test_runner = UniversalDemoRunner(args, use_gpu) File "mseg-semantic/mseg_semantic/tool/universal_demo.py", line 70, in init scales = args.scales File "/content/mseg-semantic/mseg_semantic/tool/inference_task.py", line 219, in init self.model = self.load_model(args) File "/content/mseg-semantic/mseg_semantic/tool/inference_task.py", line 264, in load_model from mseg_semantic.model.seg_hrnet import get_configured_hrnet File "/content/mseg-semantic/mseg_semantic/model/seg_hrnet.py", line 17, in import apex File "/usr/local/lib/python3.7/dist-packages/apex/init.py", line 13, in from pyramid.session import UnencryptedCookieSessionFactoryConfig ImportError: cannot import name 'UnencryptedCookieSessionFactoryConfig' from 'pyramid.session' (unknown location)

ArghyaChatterjee commented 2 years ago

I am also having the same issue. However, after some googling, I found that this issue is some what related to installing "apex".

arghya@arghya-Erazer-X7849-MD60379:~$ python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import apex
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/arghya/.local/lib/python3.6/site-packages/apex/__init__.py", line 13, in <module>
    from pyramid.session import UnencryptedCookieSessionFactoryConfig
ImportError: cannot import name 'UnencryptedCookieSessionFactoryConfig'
>>> 

I installed apex the way this repository tells me to do. After I do this:

git clone https://github.com/NVIDIA/apex
cd apex
pip3 install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

The result (main error block) has an error like this:

ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-xsywefns/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-xsywefns/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --cpp_ext --cuda_ext install --record /tmp/pip-record-oqrcssap/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/arghya/.local/include/python3.6m/apex Check the logs for full command output.

So, if you go to the official apex repo, they use:

pip3 install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
instead of
pip3 install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

When I tried to use the one mentioned in this repo, the overall error message is different but the above mentioned error block is same. I am using the following configuration: OS: Ubuntu 18.04 Cuda Version: 10.2 CUDA_HOME: /usr/local/cuda-10.2 Python Version: 3.6.9 PIP3 Version: 20.0.2 Pytorch Version: 1.6.0+cu101 I was having a problem installing dependencies for mseg-semantic repo as the requirements.txt file suggests pandas>=1.2.0. But I was able to suppress the warning with changing the pandas>=1.1.0 (it installed 1.1.5).

Can anybody help to solve this issue ??

ArghyaChatterjee commented 2 years ago

Just an update. I tried to run this repo on google colab as well as shared by the author. The colab seems to be having the same issue while installing apex. @johnwlambert you can give it a try as well if you have sometime.

ArghyaChatterjee commented 2 years ago

I can install it successfully now. The issue seems to resolved for me once I comment out line 101-107 inside setup.py file. The main problem is that it tries to check the version of pytorch (bare_metal_version) installed inside our local pc and by commenting out those lines, we are suppressing apex to not check for the pytorch version locally installed. Commenting those lines are fine according to the comment made inside setup.py file by the author. Hope this helps for everyone !!

johnwlambert commented 2 years ago

Indeed the bare metal check is what needs to be commented out, since it is overly conservative.

Looks like apex recently changed their installation instructions. I'll update the Colab notebook.

johnwlambert commented 2 years ago

@ArghyaChatterjee @EmanuelNk Thanks again for flagging this issue.

I removed the apex dependency by switching to Pytorch's SyncBatchNorm for model inference. Could you try out the Colab demo now here? It should run without issues now.