Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Making the BaseOptions class compatible with jupyter notebooks #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Saad135
Copy link
Contributor

@Saad135 Saad135 commented Jun 10, 2022

Feat: Modify BaseOptions class to make it compatible with Jupyter Notebooks

For the argument parser to be used in Jupyter Notebooks, the command line arguments need to be manually put in a list and the passed to the parser. This change allows the option to pass either a list or None to the parser. If used within a script, None is passed to the parser and then the parser reads the command line arguments from the terminal. If a list is passed, the parser reads the arguments from the list.

Before the change, None was the passed to the parser by default and thus it could not be used with a notebook.

The code inside the training and testing scripts, i.e. train.py and test.py, remains the same. Below is an example as to how the TrainOptions.parse() method is used in Jupyter Notebooks.

from options.train_options import TrainOptions
opt = TrainOptions().parse(['--dataroot', './', '--batchSize', '8', '--fineSize', '124'])

As for the training with a python script, such as train.py, there needs to be no change while calling the parse method. For example:

from options.train_options import TrainOptions
opt = TrainOptions().parse()

Other changes include deleting the byte-compiled .pyc files. Presence of these files cause an error when the code is used in jupyter notebooks. The .pyc files are auto-generated during compilation and placed in the __pycache__ folder. A .gitignore file was also added, which is used to manage the files that is supposed to be excluded from version control. For example, Byte-compiled files, environment variables, etc.

…books

For the parser to be used in jupyter notebooks, the command line arguments need to be manually put in a list and the passed to the parser.
This change allows the option to pass either a list or none to the parser.
If used within a script, None is passed to the parser and then the parser reads the command line args from the terminal.
If a list is passed, the parser reads the arguments from the list.

Before the change, None was the passed to the parser by default and thus it could not be used with a notebook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant