C.W.K.
Stream
Lesson 03 of 05 · published

KerasCV, KerasHub, Keras 3의 수렴

~13 min · keras-cv, keras-hub, keras3, multi-backend

Level 0Level 0
0 XP0/78 lessons0/17 achievements
0/100 XP to next level100 XP to go0% complete

Framework 전쟁 위의 통합 layer

KerasCV는 모듈식 computer vision 컴포넌트 제공 — pretrained backbone, preprocessing layer, augmentation pipeline, 완전한 task model — Keras 3 위에 multi-backend 호환.

KerasHub (구 KerasNLP)는 LLaMA 3, Gemma, BERT, GPT-2, Whisper 포함 pretrained 언어 model 제공. 한 줄 로드 + fine-tune.

Keras 3가 주요 architectural shift: Keras가 TensorFlow, JAX, PyTorch 백엔드 위에서 다 돌아. TF vs JAX research 긴장 해소하는 수렴 layer. Model 한 번 짜고, 환경변수 하나로 백엔드 전환. Backend-agnostic 수학엔 tf.* / jnp.* / torch.* 대신 keras.ops 써.

Code

KerasCV — object detection, augmentation·python
import keras_cv
import keras

# pip install keras-cv

# YOLOv8 object detection (COCO pretrained)
yolo = keras_cv.models.YOLOV8Detector.from_preset(
    "yolo_v8_m_pascalvoc", num_classes=20,
)

# Image classification with pretrained backbone
backbone = keras_cv.models.EfficientNetV2Backbone.from_preset(
    "efficientnetv2_s_imagenet"
)
model = keras_cv.models.ImageClassifier(
    backbone=backbone, num_classes=10,
)

# Advanced data augmentation
augmenter = keras_cv.layers.Augmenter(layers=[
    keras_cv.layers.RandomFlip(),
    keras_cv.layers.RandAugment(value_range=(0, 255)),
    keras_cv.layers.MixUp(alpha=0.2),
    keras_cv.layers.CutMix(alpha=0.2),
])
KerasHub — LLM 세 줄·python
import keras_hub
import tensorflow as tf

# pip install keras-hub

# BERT fine-tuning (one-liner)
classifier = keras_hub.models.BertTextClassifier.from_preset(
    "bert_base_en_uncased", num_classes=5,
)
classifier.compile(
    optimizer=tf.keras.optimizers.Adam(5e-5),
    loss='sparse_categorical_crossentropy',
    metrics=['accuracy'],
)
classifier.fit(train_ds, validation_data=val_ds, epochs=3)

# LLM text generation
llm = keras_hub.models.Llama3CausalLM.from_preset("llama3_instruct_8b_en")
print(llm.generate("Explain TensorFlow in one sentence:", max_length=64))

# Whisper speech-to-text
whisper = keras_hub.models.WhisperAudioToText.from_preset("whisper_base_en")
Keras 3 — backend-agnostic 코드·python
import os
os.environ["KERAS_BACKEND"] = "jax"   # or "tensorflow", "torch"

import keras
from keras import ops

class MyLayer(keras.layers.Layer):
    def call(self, x):
        # Use keras.ops, NOT tf.* / jnp.* / torch.*
        # These work identically across all three backends
        x = ops.matmul(x, self.kernel)
        x = ops.relu(x)
        return ops.softmax(x)

# Train with JAX for TPU performance
os.environ["KERAS_BACKEND"] = "jax"
model = keras.Sequential([...])
model.fit(train_data, epochs=10)

# Export framework-agnostically
model.save("model.keras")

# Reload and serve with TensorFlow
os.environ["KERAS_BACKEND"] = "tensorflow"
production_model = keras.saving.load_model("model.keras")

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.