{"id":13693003,"url":"https://github.com/keras-team/keras-cv","last_synced_at":"2025-05-13T19:17:24.651Z","repository":{"id":36972927,"uuid":"265079853","full_name":"keras-team/keras-cv","owner":"keras-team","description":"Industry-strength Computer Vision workflows with Keras","archived":false,"fork":false,"pushed_at":"2025-04-18T18:11:16.000Z","size":26350,"stargazers_count":1037,"open_issues_count":130,"forks_count":334,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-27T20:01:49.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keras-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-05-18T22:39:21.000Z","updated_at":"2025-04-26T17:29:47.000Z","dependencies_parsed_at":"2023-12-27T21:06:23.238Z","dependency_job_id":"49da7563-46b6-4874-bcfc-e3fece379baf","html_url":"https://github.com/keras-team/keras-cv","commit_stats":{"total_commits":1208,"total_committers":104,"mean_commits":"11.615384615384615","dds":0.8062913907284768,"last_synced_commit":"ba2556c98d2e122c6b7c9b2f6a94097548a8ee8a"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keras-team%2Fkeras-cv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keras-team%2Fkeras-cv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keras-team%2Fkeras-cv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keras-team%2Fkeras-cv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keras-team","download_url":"https://codeload.github.com/keras-team/keras-cv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010828,"owners_count":21999004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T17:01:04.354Z","updated_at":"2025-05-13T19:17:24.608Z","avatar_url":"https://github.com/keras-team.png","language":"Python","funding_links":[],"categories":["Computer Vision","Building","Industry Strength Computer Vision","Repos","Core Libraries"],"sub_categories":["Others","Workflows"],"readme":"# KerasCV\n\n[![](https://github.com/keras-team/keras-cv/workflows/Tests/badge.svg?branch=master)](https://github.com/keras-team/keras-cv/actions?query=workflow%3ATests+branch%3Amaster)\n![Downloads](https://img.shields.io/pypi/dm/keras-cv.svg)\n![Python](https://img.shields.io/badge/python-v3.7.0+-success.svg)\n\n\u003e [!IMPORTANT]\n\u003e 📢 KerasCV is moving to [KerasHub](https://github.com/keras-team/keras-hub/)! 📢\n\u003e Read [the announcement](https://github.com/keras-team/keras-hub/issues/1831).\n\u003e\n\u003e KerasCV will not continue to work as is; nothing will break. All development\n\u003e of new vision models should move to KerasHub.\n\nKerasCV is a library of modular computer vision components that work natively\nwith TensorFlow, JAX, or PyTorch. Built on Keras 3, these models, layers, \nmetrics, callbacks, etc., can be trained and serialized in any framework and \nre-used in another without costly migrations. See \"Configuring your backend\" \nbelow for more details on multi-framework KerasCV.\n\n\u003cimg style=\"width: 440px; max-width: 90%;\" src=\"https://storage.googleapis.com/keras-cv/guides/keras-cv-augmentations.gif\"\u003e\n\nKerasCV can be understood as a horizontal extension of the Keras API: the\ncomponents are new first-party Keras objects that are too specialized to be\nadded to core Keras. They receive the same level of polish and backwards\ncompatibility guarantees as the core Keras API, and they are maintained by the\nKeras team.\n\nOur APIs assist in common computer vision tasks such as data augmentation,\nclassification, object detection, segmentation, image generation, and more.\nApplied computer vision engineers can leverage KerasCV to quickly assemble\nproduction-grade, state-of-the-art training and inference pipelines for all of\nthese common tasks.\n\n## Quick Links\n- [List of available models and presets](https://keras.io/api/keras_cv/models/)\n- [Developer Guides](https://keras.io/guides/keras_cv/)\n- [Contributing Guide](CONTRIBUTING.md)\n- [Call for Contributions](https://github.com/keras-team/keras-cv/issues?q=is%3Aopen+is%3Aissue+label%3Acontribution-welcome)\n- [API Design Guidelines](API_DESIGN.md)\n\n## Installation\nKerasCV supports both Keras 2 and Keras 3. We recommend Keras 3 for all new \nusers, as it enables using KerasCV models and layers with JAX, TensorFlow and \nPyTorch.\n\n### Keras 2 Installation\n\nTo install the latest KerasCV release with Keras 2, simply run:\n\n```\npip install --upgrade keras-cv tensorflow\n```\n\n### Keras 3 Installation\n\nThere are currently two ways to install Keras 3 with KerasCV. To install the\nlatest changes for KerasCV and Keras, you can use our nightly package.\n\n\n```\npip install --upgrade keras-cv-nightly tf-nightly\n```\n\nTo install the stable versions of KerasCV and Keras 3, you should install Keras\n3 **after** installing KerasCV. This is a temporary step while TensorFlow is\npinned to Keras 2, and will no longer be necessary after TensorFlow 2.16.\n\n```\npip install --upgrade keras-cv tensorflow\npip install --upgrade keras\n```\n\u003e [!IMPORTANT]\n\u003e Keras 3 will not function with TensorFlow 2.14 or earlier.\n\n## Configuring your backend\n\nIf you have Keras 3 installed in your environment (see installation above),\nyou can use KerasCV with any of JAX, TensorFlow and PyTorch. To do so, set the\n`KERAS_BACKEND` environment variable. For example:\nso by setting the `KERAS_BACKEND` environment variable. For example:\n\n```shell\nexport KERAS_BACKEND=jax\n```\n\nOr in Colab, with:\n\n```python\nimport os\nos.environ[\"KERAS_BACKEND\"] = \"jax\"\n\nimport keras_cv\n```\n\n\u003e [!IMPORTANT]\n\u003e Make sure to set the `KERAS_BACKEND` before import any Keras libraries, it\n\u003e will be used to set up Keras when it is first imported.\n\nOnce that configuration step is done, you can just import KerasCV and start\nusing it on top of your backend of choice:\n\n```python\nimport keras_cv\nimport keras\n\nfilepath = keras.utils.get_file(origin=\"https://i.imgur.com/gCNcJJI.jpg\")\nimage = np.array(keras.utils.load_img(filepath))\nimage_resized = keras.ops.image.resize(image, (640, 640))[None, ...]\n\nmodel = keras_cv.models.YOLOV8Detector.from_preset(\n    \"yolo_v8_m_pascalvoc\",\n    bounding_box_format=\"xywh\",\n)\npredictions = model.predict(image_resized)\n```\n\n## Quickstart\n\n```python\nimport tensorflow as tf\nimport keras_cv\nimport tensorflow_datasets as tfds\nimport keras\n\n# Create a preprocessing pipeline with augmentations\nBATCH_SIZE = 16\nNUM_CLASSES = 3\naugmenter = keras_cv.layers.Augmenter(\n    [\n        keras_cv.layers.RandomFlip(),\n        keras_cv.layers.RandAugment(value_range=(0, 255)),\n        keras_cv.layers.CutMix(),\n    ],\n)\n\ndef preprocess_data(images, labels, augment=False):\n    labels = tf.one_hot(labels, NUM_CLASSES)\n    inputs = {\"images\": images, \"labels\": labels}\n    outputs = inputs\n    if augment:\n        outputs = augmenter(outputs)\n    return outputs['images'], outputs['labels']\n\ntrain_dataset, test_dataset = tfds.load(\n    'rock_paper_scissors',\n    as_supervised=True,\n    split=['train', 'test'],\n)\ntrain_dataset = train_dataset.batch(BATCH_SIZE).map(\n    lambda x, y: preprocess_data(x, y, augment=True),\n        num_parallel_calls=tf.data.AUTOTUNE).prefetch(\n            tf.data.AUTOTUNE)\ntest_dataset = test_dataset.batch(BATCH_SIZE).map(\n    preprocess_data, num_parallel_calls=tf.data.AUTOTUNE).prefetch(\n        tf.data.AUTOTUNE)\n\n# Create a model using a pretrained backbone\nbackbone = keras_cv.models.EfficientNetV2Backbone.from_preset(\n    \"efficientnetv2_b0_imagenet\"\n)\nmodel = keras_cv.models.ImageClassifier(\n    backbone=backbone,\n    num_classes=NUM_CLASSES,\n    activation=\"softmax\",\n)\nmodel.compile(\n    loss='categorical_crossentropy',\n    optimizer=keras.optimizers.Adam(learning_rate=1e-5),\n    metrics=['accuracy']\n)\n\n# Train your model\nmodel.fit(\n    train_dataset,\n    validation_data=test_dataset,\n    epochs=8,\n)\n```\n\n## Contributors\nIf you'd like to contribute, please see our [contributing guide](CONTRIBUTING.md).\n\nTo find an issue to tackle, please check our [call for contributions](CALL_FOR_CONTRIBUTIONS.md).\n\nWe would like to leverage/outsource the Keras community not only for bug reporting,\nbut also for active development for feature delivery. To achieve this, here is the predefined\nprocess for how to contribute to this repository:\n\n1) Contributors are always welcome to help us fix an issue, add tests, better documentation.\n2) If contributors would like to create a backbone, we usually require a pre-trained weight set\nwith the model for one dataset as the first PR, and a training script as a follow-up. The training script will preferably help us reproduce the results claimed from paper. The backbone should be generic but the training script can contain paper specific parameters such as learning rate schedules and weight decays. The training script will be used to produce leaderboard results.\nExceptions apply to large transformer-based models which are difficult to train. If this is the case,\ncontributors should let us know so the team can help in training the model or providing GCP resources.\n3) If contributors would like to create a meta arch, please try to be aligned with our roadmap and create a PR for design review to make sure the meta arch is modular.\n4) If contributors would like to create a new input formatting which is not in our roadmap for the next 6 months, e.g., keypoint, please create an issue and ask for a sponsor.\n5) If contributors would like to support a new task which is not in our roadmap for the next 6 months, e.g., 3D reconstruction, please create an issue and ask for a sponsor.\n\nThank you to all of our wonderful contributors!\n\n\u003ca href=\"https://github.com/keras-team/keras-cv/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=keras-team/keras-cv\" /\u003e\n\u003c/a\u003e\n\n## Pretrained Weights\nMany models in KerasCV come with pre-trained weights.\nWith the exception of StableDiffusion and the standard Vision Transformer, all of these weights are trained using Keras and\nKerasCV components and training scripts in this repository.\nWhile some models are not trained with the same parameters or preprocessing pipeline\nas defined in their original publications, the KerasCV team ensures strong numerical performance.\nPerformance metrics for the provided pre-trained weights can be found\nin the training history for each documented task.\nAn example of this can be found in the ImageNet classification training\n[history for backbone models](examples/training/classification/imagenet/training_history.json).\nAll results are reproducible using the training scripts in this repository.\n\nHistorically, many models have been trained on image datasets rescaled via manually\ncrafted normalization schemes.\nThe most common variant of manually crafted normalization scheme is subtraction of the\nimagenet mean pixel followed by standard deviation normalization based on the imagenet\npixel standard deviation.\nThis scheme is an artifact of the days of manual feature engineering, but is no longer\nrequired to score state of the art scores using modern deep learning architectures.\nDue to this, KerasCV is standardized to operate on images that have been rescaled using\na simple `1/255` rescaling layer.\nThis can be seen in all KerasCV training pipelines and code examples.\n\n## Custom Ops\nNote that in some of the 3D Object Detection layers, custom TF ops are used. The\nbinaries for these ops are not shipped in our PyPi package in order to keep our\nwheels pure-Python.\n\nIf you'd like to use these custom ops, you can install from source using the\ninstructions below.\n\n### Installing KerasCV with Custom Ops from Source\n\nInstalling custom ops from source requires the [Bazel](https://bazel.build/) build\nsystem (version \u003e= 5.4.0). Steps to install Bazel can be [found here](https://github.com/keras-team/keras/blob/v2.11.0/.devcontainer/Dockerfile#L21-L23).\n\n```\ngit clone https://github.com/keras-team/keras-cv.git\ncd keras-cv\n\npython3 build_deps/configure.py\n\nbazel build build_pip_pkg\nexport BUILD_WITH_CUSTOM_OPS=true\nbazel-bin/build_pip_pkg wheels\n\npip install wheels/keras_cv-*.whl\n```\n\nNote that GitHub actions exist to release KerasCV with custom ops, but are\ncurrently disabled. You can use these [actions](https://github.com/keras-team/keras-cv/blob/master/.github/workflows/release.yml)\nin your own fork to create wheels for Linux (manylinux2014), MacOS (both x86 and ARM),\nand Windows.\n\n## Disclaimer\n\nKerasCV provides access to pre-trained models via the `keras_cv.models` API.\nThese pre-trained models are provided on an \"as is\" basis, without warranties\nor conditions of any kind.\nThe following underlying models are provided by third parties, and are subject to separate\nlicenses:\nStableDiffusion, Vision Transformer\n\n## Citing KerasCV\n\nIf KerasCV helps your research, we appreciate your citations.\nHere is the BibTeX entry:\n\n```bibtex\n@misc{wood2022kerascv,\n  title={KerasCV},\n  author={Wood, Luke and Tan, Zhenyu and Stenbit, Ian and Bischof, Jonathan and Zhu, Scott and Chollet, Fran\\c{c}ois and Sreepathihalli, Divyashree and Sampath, Ramesh and others},\n  year={2022},\n  howpublished={\\url{https://github.com/keras-team/keras-cv}},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeras-team%2Fkeras-cv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeras-team%2Fkeras-cv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeras-team%2Fkeras-cv/lists"}