File size: 616 Bytes
89683ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Load the model
model_name = "SmilingWolf/wd-eva02-large-tagger-v3"
tagger = pipeline("image-classification", model=model_name)

# Define the prediction function
def predict(image):
    results = tagger(image)
    return {result["label"]: result["score"] for result in results}

# Create a Gradio interface
iface = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs=gr.Label(num_top_classes=10),
    title="Danbooru AI Tagger",
    description="Automatically tag Danbooru-style images using AI."
)

# Launch the interface
iface.launch()