Instructions to use prithivMLmods/Multisource-121-DomainNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Multisource-121-DomainNet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="prithivMLmods/Multisource-121-DomainNet") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForImageClassification processor = AutoProcessor.from_pretrained("prithivMLmods/Multisource-121-DomainNet") model = AutoModelForImageClassification.from_pretrained("prithivMLmods/Multisource-121-DomainNet", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files3 unmodified lines456789125 unmodified lines1351361371383 unmodified lines- TNILab/DomainNet_FL---```py125 unmodified linesaccuracy 0.7995 32670macro avg 0.8052 0.7995 0.8006 32670weighted avg 0.8052 0.7995 0.8006 32670```3 unmodified lines45678910111213125 unmodified lines1391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593 unmodified lines- TNILab/DomainNet_FL---# **Multisource-121-DomainNet**> **Multisource-121-DomainNet** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify images into 121 domain categories using the **SiglipForImageClassification** architecture.```py125 unmodified linesaccuracy 0.7995 32670macro avg 0.8052 0.7995 0.8006 32670weighted avg 0.8052 0.7995 0.8006 32670```The model categorizes images into the following 121 classes:- **Class 0:** "barn"- **Class 1:** "baseball_bat"- **Class 2:** "basket"- **Class 3:** "beach"- **Class 4:** "bear"- **Class 5:** "beard"- **Class 6:** "bee"- **Class 7:** "bird"- **Class 8:** "blueberry"- **Class 9:** "bowtie"- **Class 10:** "bracelet"- **Class 11:** "brain"- **Class 12:** "bread"- **Class 13:** "broccoli"- **Class 14:** "bus"- **Class 15:** "butterfly"- **Class 16:** "circle"- **Class 17:** "cloud"- **Class 18:** "cruise_ship"- **Class 19:** "dolphin"- **Class 20:** "dumbbell"- **Class 21:** "elephant"- **Class 22:** "eye"- **Class 23:** "eyeglasses"- **Class 24:** "feather"- **Class 25:** "fish"- **Class 26:** "flower"- **Class 27:** "foot"- **Class 28:** "frog"- **Class 29:** "giraffe"- **Class 30:** "goatee"- **Class 31:** "golf_club"- **Class 32:** "grapes"- **Class 33:** "grass"- **Class 34:** "guitar"- **Class 35:** "hamburger"- **Class 36:** "hand"- **Class 37:** "hat"- **Class 38:** "headphones"- **Class 39:** "helicopter"- **Class 40:** "hexagon"- **Class 41:** "hockey_stick"- **Class 42:** "horse"- **Class 43:** "hourglass"- **Class 44:** "house"- **Class 45:** "ice_cream"- **Class 46:** "jacket"- **Class 47:** "ladder"- **Class 48:** "leg"- **Class 49:** "lipstick"- **Class 50:** "megaphone"- **Class 51:** "monkey"- **Class 52:** "moon"- **Class 53:** "mushroom"- **Class 54:** "necklace"- **Class 55:** "owl"- **Class 56:** "panda"- **Class 57:** "pear"- **Class 58:** "peas"- **Class 59:** "penguin"- **Class 60:** "pig"- **Class 61:** "pillow"- **Class 62:** "pineapple"- **Class 63:** "pizza"- **Class 64:** "pool"- **Class 65:** "popsicle"- **Class 66:** "rabbit"- **Class 67:** "rhinoceros"- **Class 68:** "rifle"- **Class 69:** "river"- **Class 70:** "sailboat"- **Class 71:** "sandwich"- **Class 72:** "sea_turtle"- **Class 73:** "shark"- **Class 74:** "shoe"- **Class 75:** "skyscraper"- **Class 76:** "snorkel"- **Class 77:** "snowman"- **Class 78:** "soccer_ball"- **Class 79:** "speedboat"- **Class 80:** "spider"- **Class 81:** "spoon"- **Class 82:** "square"- **Class 83:** "squirrel"- **Class 84:** "stethoscope"- **Class 85:** "strawberry"- **Class 86:** "streetlight"- **Class 87:** "submarine"- **Class 88:** "suitcase"- **Class 89:** "sun"- **Class 90:** "sweater"- **Class 91:** "sword"- **Class 92:** "table"- **Class 93:** "teapot"- **Class 94:** "teddy-bear"- **Class 95:** "telephone"- **Class 96:** "tent"- **Class 97:** "The_Eiffel_Tower"- **Class 98:** "The_Great_Wall_of_China"- **Class 99:** "The_Mona_Lisa"- **Class 100:** "tiger"- **Class 101:** "toaster"- **Class 102:** "tooth"- **Class 103:** "tornado"- **Class 104:** "tractor"- **Class 105:** "train"- **Class 106:** "tree"- **Class 107:** "triangle"- **Class 108:** "trombone"- **Class 109:** "truck"- **Class 110:** "trumpet"- **Class 111:** "umbrella"- **Class 112:** "vase"- **Class 113:** "violin"- **Class 114:** "watermelon"- **Class 115:** "whale"- **Class 116:** "windmill"- **Class 117:** "wine_glass"- **Class 118:** "yoga"- **Class 119:** "zebra"- **Class 120:** "zigzag"# **Run with Transformers🤗**```python!pip install -q transformers torch pillow gradio``````pythonimport gradio as grfrom transformers import AutoImageProcessor, SiglipForImageClassificationfrom transformers.image_utils import load_imagefrom PIL import Imageimport torch# Load model and processormodel_name = "prithivMLmods/Multisource-121-DomainNet"model = SiglipForImageClassification.from_pretrained(model_name)processor = AutoImageProcessor.from_pretrained(model_name)def multisource_classification(image):"""Predicts the domain category for an input image."""# Convert the input numpy array to a PIL Image and ensure it is in RGB formatimage = Image.fromarray(image).convert("RGB")# Process the image and convert it to model inputsinputs = processor(images=image, return_tensors="pt")# Get model predictions without gradient calculationswith torch.no_grad():outputs = model(**inputs)logits = outputs.logits# Convert logits to probabilities using softmaxprobs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()# Mapping from class indices to domain labelslabels = {"0": "barn", "1": "baseball_bat", "2": "basket", "3": "beach", "4": "bear","5": "beard", "6": "bee", "7": "bird", "8": "blueberry", "9": "bowtie","10": "bracelet", "11": "brain", "12": "bread", "13": "broccoli", "14": "bus","15": "butterfly", "16": "circle", "17": "cloud", "18": "cruise_ship", "19": "dolphin","20": "dumbbell", "21": "elephant", "22": "eye", "23": "eyeglasses", "24": "feather","25": "fish", "26": "flower", "27": "foot", "28": "frog", "29": "giraffe","30": "goatee", "31": "golf_club", "32": "grapes", "33": "grass", "34": "guitar","35": "hamburger", "36": "hand", "37": "hat", "38": "headphones", "39": "helicopter","40": "hexagon", "41": "hockey_stick", "42": "horse", "43": "hourglass", "44": "house","45": "ice_cream", "46": "jacket", "47": "ladder", "48": "leg", "49": "lipstick","50": "megaphone", "51": "monkey", "52": "moon", "53": "mushroom", "54": "necklace","55": "owl", "56": "panda", "57": "pear", "58": "peas", "59": "penguin","60": "pig", "61": "pillow", "62": "pineapple", "63": "pizza", "64": "pool","65": "popsicle", "66": "rabbit", "67": "rhinoceros", "68": "rifle", "69": "river","70": "sailboat", "71": "sandwich", "72": "sea_turtle", "73": "shark", "74": "shoe","75": "skyscraper", "76": "snorkel", "77": "snowman", "78": "soccer_ball", "79": "speedboat","80": "spider", "81": "spoon", "82": "square", "83": "squirrel", "84": "stethoscope","85": "strawberry", "86": "streetlight", "87": "submarine", "88": "suitcase", "89": "sun","90": "sweater", "91": "sword", "92": "table", "93": "teapot", "94": "teddy-bear","95": "telephone", "96": "tent", "97": "The_Eiffel_Tower", "98": "The_Great_Wall_of_China","99": "The_Mona_Lisa", "100": "tiger", "101": "toaster", "102": "tooth", "103": "tornado","104": "tractor", "105": "train", "106": "tree", "107": "triangle", "108": "trombone","109": "truck", "110": "trumpet", "111": "umbrella", "112": "vase", "113": "violin","114": "watermelon", "115": "whale", "116": "windmill", "117": "wine_glass", "118": "yoga","119": "zebra", "120": "zigzag"}# Create a dictionary mapping each label to its corresponding probability (rounded)predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}return predictions# Create Gradio interfaceiface = gr.Interface(fn=multisource_classification,inputs=gr.Image(type="numpy"),outputs=gr.Label(label="Prediction Scores"),title="Multisource-121-DomainNet Classification",description="Upload an image to classify it into one of 121 domain categories.")# Launch the appif __name__ == "__main__":iface.launch()```---# **Intended Use:**The **Multisource-121-DomainNet** model is designed for multi-source image classification. It can categorize images into a diverse set of 121 domains, covering various objects, scenes, and landmarks. Potential use cases include:- **Cross-Domain Image Analysis:** Enabling robust classification across a wide range of visual domains.- **Multimedia Retrieval:** Assisting in content organization and retrieval in multimedia databases.- **Computer Vision Research:** Serving as a benchmark for evaluating domain adaptation and transfer learning techniques.- **Interactive Applications:** Enhancing user interfaces with diverse, real-time image recognition capabilities.
README.md+222-1