Instructions to use vickygupta1996/VGG16_Sign_Verification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use vickygupta1996/VGG16_Sign_Verification with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy), and from_pretrained_keras was removed in huggingface_hub 1.0. # See https://github.com/keras-team/tf-keras for more details. # !pip install "huggingface_hub<1.0" tf_keras from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("vickygupta1996/VGG16_Sign_Verification") - Notebooks
- Google Colab
- Kaggle
Download SignatureDetection/ultralytics/tests/test_engine.py from vickygupta1996/VGG16_Sign_Verification: direct link, hf CLI and curl.
- Browser
- Download file 4.38 kB
-
https://huggingface.co/vickygupta1996/VGG16_Sign_Verification/resolve/main/SignatureDetection/ultralytics/tests/test_engine.py
- Command line
-
hf download hf://vickygupta1996/VGG16_Sign_Verification/SignatureDetection/ultralytics/tests/test_engine.py
-
curl -L -o test_engine.py https://huggingface.co/vickygupta1996/VGG16_Sign_Verification/resolve/main/SignatureDetection/ultralytics/tests/test_engine.py
4.38 kB
| # Ultralytics YOLO 🚀, AGPL-3.0 license | |
| from pathlib import Path | |
| from ultralytics import YOLO | |
| from ultralytics.cfg import get_cfg | |
| from ultralytics.engine.exporter import Exporter | |
| from ultralytics.models.yolo import classify, detect, segment | |
| from ultralytics.utils import ASSETS, DEFAULT_CFG, SETTINGS | |
| CFG_DET = 'yolov8n.yaml' | |
| CFG_SEG = 'yolov8n-seg.yaml' | |
| CFG_CLS = 'yolov8n-cls.yaml' # or 'squeezenet1_0' | |
| CFG = get_cfg(DEFAULT_CFG) | |
| MODEL = Path(SETTINGS['weights_dir']) / 'yolov8n' | |
| def test_func(*args): # noqa | |
| print('callback test passed') | |
| def test_export(): | |
| exporter = Exporter() | |
| exporter.add_callback('on_export_start', test_func) | |
| assert test_func in exporter.callbacks['on_export_start'], 'callback test failed' | |
| f = exporter(model=YOLO(CFG_DET).model) | |
| YOLO(f)(ASSETS) # exported model inference | |
| def test_detect(): | |
| overrides = {'data': 'coco8.yaml', 'model': CFG_DET, 'imgsz': 32, 'epochs': 1, 'save': False} | |
| CFG.data = 'coco8.yaml' | |
| CFG.imgsz = 32 | |
| # Trainer | |
| trainer = detect.DetectionTrainer(overrides=overrides) | |
| trainer.add_callback('on_train_start', test_func) | |
| assert test_func in trainer.callbacks['on_train_start'], 'callback test failed' | |
| trainer.train() | |
| # Validator | |
| val = detect.DetectionValidator(args=CFG) | |
| val.add_callback('on_val_start', test_func) | |
| assert test_func in val.callbacks['on_val_start'], 'callback test failed' | |
| val(model=trainer.best) # validate best.pt | |
| # Predictor | |
| pred = detect.DetectionPredictor(overrides={'imgsz': [64, 64]}) | |
| pred.add_callback('on_predict_start', test_func) | |
| assert test_func in pred.callbacks['on_predict_start'], 'callback test failed' | |
| result = pred(source=ASSETS, model=f'{MODEL}.pt') | |
| assert len(result), 'predictor test failed' | |
| overrides['resume'] = trainer.last | |
| trainer = detect.DetectionTrainer(overrides=overrides) | |
| try: | |
| trainer.train() | |
| except Exception as e: | |
| print(f'Expected exception caught: {e}') | |
| return | |
| Exception('Resume test failed!') | |
| def test_segment(): | |
| overrides = {'data': 'coco8-seg.yaml', 'model': CFG_SEG, 'imgsz': 32, 'epochs': 1, 'save': False} | |
| CFG.data = 'coco8-seg.yaml' | |
| CFG.imgsz = 32 | |
| # YOLO(CFG_SEG).train(**overrides) # works | |
| # trainer | |
| trainer = segment.SegmentationTrainer(overrides=overrides) | |
| trainer.add_callback('on_train_start', test_func) | |
| assert test_func in trainer.callbacks['on_train_start'], 'callback test failed' | |
| trainer.train() | |
| # Validator | |
| val = segment.SegmentationValidator(args=CFG) | |
| val.add_callback('on_val_start', test_func) | |
| assert test_func in val.callbacks['on_val_start'], 'callback test failed' | |
| val(model=trainer.best) # validate best.pt | |
| # Predictor | |
| pred = segment.SegmentationPredictor(overrides={'imgsz': [64, 64]}) | |
| pred.add_callback('on_predict_start', test_func) | |
| assert test_func in pred.callbacks['on_predict_start'], 'callback test failed' | |
| result = pred(source=ASSETS, model=f'{MODEL}-seg.pt') | |
| assert len(result), 'predictor test failed' | |
| # Test resume | |
| overrides['resume'] = trainer.last | |
| trainer = segment.SegmentationTrainer(overrides=overrides) | |
| try: | |
| trainer.train() | |
| except Exception as e: | |
| print(f'Expected exception caught: {e}') | |
| return | |
| Exception('Resume test failed!') | |
| def test_classify(): | |
| overrides = {'data': 'imagenet10', 'model': CFG_CLS, 'imgsz': 32, 'epochs': 1, 'save': False} | |
| CFG.data = 'imagenet10' | |
| CFG.imgsz = 32 | |
| # YOLO(CFG_SEG).train(**overrides) # works | |
| # Trainer | |
| trainer = classify.ClassificationTrainer(overrides=overrides) | |
| trainer.add_callback('on_train_start', test_func) | |
| assert test_func in trainer.callbacks['on_train_start'], 'callback test failed' | |
| trainer.train() | |
| # Validator | |
| val = classify.ClassificationValidator(args=CFG) | |
| val.add_callback('on_val_start', test_func) | |
| assert test_func in val.callbacks['on_val_start'], 'callback test failed' | |
| val(model=trainer.best) | |
| # Predictor | |
| pred = classify.ClassificationPredictor(overrides={'imgsz': [64, 64]}) | |
| pred.add_callback('on_predict_start', test_func) | |
| assert test_func in pred.callbacks['on_predict_start'], 'callback test failed' | |
| result = pred(source=ASSETS, model=trainer.best) | |
| assert len(result), 'predictor test failed' | |