-
Notifications
You must be signed in to change notification settings - Fork 30.9k
Add semantic segmentation example script, no trainer #16630
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
Add semantic segmentation example script, no trainer #16630
Conversation
…ielsRogge/transformers into add_semantic_script_no_trainer
Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
This reverts commit b1a7dfe.
* refactor TF beam search * refactored generate can now properly use attention masks * add force bos/eos logit processors
* Update modeling_mpnet.py * Update modeling_ctrl.py * formatting * Formatting * Formatting * annotated FSMT * Added annotations for LED * Added Annotations for M2M * Added annotations for nystromformer * Added annotations for OpenAI * Added annotations for RAG * Removed unused imports * fix isort errors * Removed inputs_embeds docstring, corrected original * flake8 fixes * doc-builder fixes
…gface#16617) Adds logging and save/loading to the Accelerate scripts Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
* Fix doc * Make fixup Co-authored-by: Niels Rogge <nielsrogge@nielss-mbp.home>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @NielsRogge!
I added a few suggestions based on the recent upgrades to Accelerate and the new script changes that got pushed.
The other two capabilities we're trying to include in the scripts are resuming from a checkpoint as well as save_state by batch or by epoch (this is just torch.save, so slightly different than transformers save. Pick your poison on those I think.)
Nice start!
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Show resolved
Hide resolved
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
* Add inputs vector to calculate metric method * Include inputs for evaluation metrics with backwards compatibility * Prevent inputs create OOM issue and documentation details * Update style and code documentation * Fix style formatting issues * Update files format with make style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice addition! Agreed with all the changes Zach suggested as Accelerate can now handle the logging for you, and the scheduler should be passed along to prepare for better support with DeepSpeed.
This will make your example rely on Accelerate master for a couple of weeks until next release (probably next week) so you should add a warning in the Readme to install Accelerate from source. I'll put a not to adapt this after Accelerate next release.
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
Outdated
Show resolved
Hide resolved
…ate_dict (huggingface#16643) * Updated _load_pretrained_model_low_mem to check if keys are in the stored state_dict * update after conversions
* Update README.md Support Image Updates the Support image linking to our EAP page (to give it a refresh + help avoid image fatigue). Slack thread checking in with #open-source-internal on this update (https://huggingface.slack.com/archives/C021H1P1HKR/p1648838903316709) * Compressed Updated Support image * Improves Support Image Logo + Height Updated the image based on logo + size feedback. Big thanks to Bibi for making quick edits to this image.
* base model done * make style * done * added files * Apply suggestions from code review Co-authored-by: NielsRogge <48327001+NielsRogge@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> * Trigger doc build * resolved conversations * resolved conversations * seer models * minor changes * minor changes * make fixup * glob variables * minor changes * fix copies * config when possibile * resolved conflicts * resolved conflicts * resolved conflicts * CI * conversion script for 10b param * fixed for 10b model * minor updates in the doc + make style * removed unused code * Apply suggestions from code review Co-authored-by: NielsRogge <48327001+NielsRogge@users.noreply.github.com> * removed unused code * removed unused code * updated modeling_utils from main Co-authored-by: NielsRogge <48327001+NielsRogge@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <Sylvain.gugger@gmail.com>
* Add TapexTokenizer * Improve docstrings and provide option to provide answer * Remove option for pretokenized inputs * Add TAPEX to README * Fix copies * Remove option for pretokenized inputs * Initial commit: add tapex fine-tuning examples on both table-based question answering and table-based fact verification. * - Draft a README file for running the script and introducing some background. - Remove unused code lines in tabfact script. - Disable the deafult `pad_to_max_length` option which is memory-consuming. * * Support `as_target_tokenizer` function for TapexTokenizer. * Fix the do_lower_case behaviour of TapexTokenizer. * Add unit tests for target scenarios and cased/uncased scenarios for both source and target. * * Replace the label BartTokenizer with TapexTokenizer's as_target_tokenizer function. * Fix typos in tapex example README. * * fix the evaluation script - remove the property `task_name` * * Make the label space more clear for tabfact tasks * * Using a new fine-tuning script for tapex-base on tabfact. * * Remove the lowercase code outside the tokenizer - we use the tokenizer to control whether do_lower_case * Guarantee the hyper-parameter can be run without out-of-memory on 16GB card and report the new reproduced number on wikisql * * Remove the default tokenizer_name option. * Provide evaluation command. * * Support for WikiTableQuestion dataset. * Fix a typo in README. * * Fix the datasets's key name in WikiTableQuestions * Run make fixup and move test to folder * Fix quality * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Suraj Patil <surajp815@gmail.com> * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> * Apply some more suggestions from code review * Improve docstrings * Overwrite failing test * Improve comment in example scripts * Fix rebase * Add TAPEX to Auto mapping * Add TAPEX to auto config mappings * Put TAPEX higher than BART in auto mapping * Add TAPEX to doc tests Co-authored-by: Niels Rogge <nielsrogge@Nielss-MBP.localdomain> Co-authored-by: SivilTaram <qianlxc@outlook.com> Co-authored-by: Niels Rogge <nielsrogge@nielss-mbp.home> Co-authored-by: Suraj Patil <surajp815@gmail.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Niels Rogge <nielsrogge@Nielss-MacBook-Pro.local>
* add vit tf doctest with @add_code_sample_docstrings * add labels string back in Co-authored-by: Johannes Kolbe <johannes.kolbe@tech.better.team>
The defalut value of `padding` in `DataCollatorWithPadding` is `True`, not `False`.
* fix QA sample * For TF_QUESTION_ANSWERING_SAMPLE Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
* Fixed some bugs involving saving during epochs * Added tests mimicking the existing examples tests * Added in json exporting to all `no_trainer` examples for consistency
* [Trainer] tf32 arg doc * Update src/transformers/training_args.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
* ✨ update audio examples with minds dataset * 🖍 make style * 🖍 minor fixes for doctests
|
I've added all requested changes. As you can see, I'm updating the repo using commits rather than creating subfolders. |
| # Optionally push to the hub | ||
| if args.push_to_hub and accelerator.is_main_process: | ||
| feature_extractor.save_pretrained(args.output_dir) | ||
| repo.push_to_hub( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the checkpoint saved here is saved with torch.save and not save_pretrained so they're not usable with from_pretrained.
Also, you'll need to adapt the logic to resume from a checkpoint to checkout the right branch in the folder if you go this way, as everything is saved in the root of output_dir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this logic and updated the script to be aligned with the other example scripts.
|
Updated the script to create subfolders like the other examples (and these aren't pushed to the hub based on the gitignore file). |
|
Some issue with git, closing this PR in favor of a new one. |
What does this PR do?
This PR adds an example script regarding fine-tuning any model supported by the
AutoModelForSemanticSegmentationAPI on a semantic segmentation dataset, including regularly pushing to the hub during training as well as WandB logging.I switched to using Accelerate as I had a bug with the Trainer.
To do: