question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created a year ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
PnthrLeocommented, Nov 13, 2022

Just in case, I repeat my instructions to the notebook with screenshots:

  1. Run this cell. image
  2. Then click on ‘Restart runtime’. image
  3. After this do not run “Installation” cell. Run only “Code” cells.

I check it again, it should work 😃

1reaction
shravankumar147commented, Oct 26, 2022

Thanks for the input @krshrimali , I will test it in some time and update back here.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found