Run this model with HF Jobs
Run Thastp/efficientnet_b1 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Thastp/efficientnet_b1. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Thastp/efficientnet_b1 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Thastp/efficientnet_b1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Thastp/efficientnet_b1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Thastp/efficientnet_b1", trust_remote_code=True) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Thastp/efficientnet_b1", trust_remote_code=True) model = AutoModelForImageClassification.from_pretrained("Thastp/efficientnet_b1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload processor
Browse files12345672 unmodified lines101112910111213141314151617181920212223242526272829303132333435363738394041424344454647484950515219535455565758592160616263from PIL import Image
from torch import Tensor, stack
from typing import Union, List
from transformers.image_processing_utils import BaseImageProcessor, BatchFeature
from timm import create_model
from timm.data import resolve_data_config2 unmodified linesclass EfficientNetImageProcessor(BaseImageProcessor):
model_input_names = ["pixel_values"]
def __init__(self,
model_name: str,
**kwargs
):
super().__init__(**kwargs)
def __init__(
self,
model_name: str,
**kwargs,
):
self.model_name = model_name
self.config = resolve_data_config({}, model=create_model(model_name, pretrained=False))
super().__init__(**kwargs)
def preprocess(
self,
images: Union[List[Union[Image.Image, Tensor]], Image.Image, Tensor],
) -> BatchFeature:
"""
Preprocesses input images by applying transformations and returning them as a BatchFeature.
Parameters
----------
images : Union[List[PIL.Image.Image, torch.Tensor], PIL.Image.Image, torch.Tensor]
A single image or a list of images in one of the accepted formats.
Returns
-------
BatchFeature
A batch of transformed images
"""
images = [images] if not isinstance(images, list) else images
# TEST: empty list
if len(images) == 0:
raise ValueError("Received an empty list of images")
# TEST: validate input type
test_image = images[0]
if not isinstance(images[0], (Image.Image, Tensor)):
raise TypeError(
f"Expected image to be of type PIL.Image.Image, torch.Tensor, or numpy.ndarray, "
f"but got {type(test_image).__name__} instead."
)
def preprocess(self, image):
# Apply transformations
transforms = create_transform(**self.config)
transformed_images = [transforms(image) for image in images]
# Convert to batch tensor
transformed_image_tensors = stack(transformed_images)
data = {'pixel_values': transforms(image).unsqueeze(0)}
data = {'pixel_values': transformed_image_tensors}
return BatchFeature(data=data)
__all__ = [image_processing_efficientnet.py+47-8