NameError: name 'Parser' is not defined
See original GitHub issue🐛 Bug
When trying out object detection example, got the below error at datamodule.
NameError: name 'Parser' is not defined
Code sample
datamodule = ObjectDetectionData.from_coco(
train_folder="data/coco128/images/train2017/",
train_ann_file="data/coco128/annotations/instances_train2017.json",
val_split=0.1,
transform_kwargs={"image_size": 512},
batch_size=4,
)
To Reproduce
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
[<ipython-input-5-56b8a0b8bc9b>](https://localhost:8080/#) in <module>
4 val_split=0.1,
5 transform_kwargs={"image_size": 512},
----> 6 batch_size=4,
7 )
5 frames
[/usr/local/lib/python3.7/dist-packages/flash/core/integrations/icevision/data.py](https://localhost:8080/#) in load_data(self, root, ann_file, parser, parser_kwargs)
43 parser_kwargs = {} if parser_kwargs is None else parser_kwargs
44 unwrapped_parser = getattr(parser, "func", parser)
---> 45 if inspect.isclass(unwrapped_parser) and issubclass(unwrapped_parser, Parser):
46 parser = parser(ann_file, root, **parser_kwargs)
47 elif isinstance(unwrapped_parser, Callable):
NameError: name 'Parser' is not defined
Expected behavior
It should create a data module for further computations.
Environment
- OS (e.g., Linux): Linux
- Python version: Python 3.7.15
- PyTorch/Lightning/Flash Version (e.g., 1.10/1.5/0.7): Flash 0.8.0
- GPU models and configuration: Colab GPU
- Any other relevant information: Running on Google Colab
Issue Analytics
- State:
- Created a year ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
NameError: name 'Parser' is not defined - Stack Overflow
First, you need to create a parser. parser = argparse.ArgumentParser(). Then you need to call it's parse_args method.
Read more >NameError: name 'parser' is not defined #189 - olofk/fusesoc
A up-to-date fusesoc checkout (master) gives the following error when called without any command line arguments: ...
Read more >Python argparse error NameError name file is not defined
I am trying to run a speech to text script and here is a part of that code where I am getting error:...
Read more >NameError: name 'u1' is not defined (on parser code Python)
Most have print() in main() function. There are serval other problem if i do a test,u1,u2 will have no output.
Read more >NameError: global name 'parser' is not defined - Jython tracker
Title: NameError: global name 'parser' is not defined ... will never support either c) is pending deprecation and was removed in Python 3...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just in case, I repeat my instructions to the notebook with screenshots:
I check it again, it should work 😃
Thanks for the input @krshrimali , I will test it in some time and update back here.