Instructions to use KristofGaming39/Zer0Shot-image-RobloxCharacters with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use KristofGaming39/Zer0Shot-image-RobloxCharacters with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://KristofGaming39/Zer0Shot-image-RobloxCharacters") - Notebooks
- Google Colab
- Kaggle
Download codeforpredicting.py from KristofGaming39/Zer0Shot-image-RobloxCharacters: direct link, hf CLI and curl.
- Browser
- Download file 905 Bytes
-
https://huggingface.co/KristofGaming39/Zer0Shot-image-RobloxCharacters/resolve/main/codeforpredicting.py
- Command line
-
hf download hf://KristofGaming39/Zer0Shot-image-RobloxCharacters/codeforpredicting.py
-
curl -L -o codeforpredicting.py https://huggingface.co/KristofGaming39/Zer0Shot-image-RobloxCharacters/resolve/main/codeforpredicting.py
905 Bytes
| import torch | |
| import torchvision | |
| from torchvision.transforms import transforms | |
| from PIL import Image | |
| model = torchvision.models.resnet50(pretrained=False) | |
| model.fc = torch.nn.Linear(in_features=2048, out_features=1) | |
| model.load_state_dict(torch.load('/content/zero_shot_classification_model.pth')) | |
| model.eval() | |
| test_transform = transforms.Compose([ | |
| transforms.Resize((224, 224)), | |
| transforms.ToTensor(), | |
| transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) | |
| ]) | |
| test_image_path = '/content/test_img.png' # Replace with your own test image path! | |
| test_image = Image.open(test_image_path).convert('RGB') | |
| test_image = test_transform(test_image) | |
| test_image = test_image.unsqueeze(0) | |
| with torch.no_grad(): | |
| prediction = model(test_image) | |
| probability = torch.sigmoid(prediction).item() | |
| print(f"The probability of the image being a Roblox character is: {probability*100}%") |