import gradio as gr from transformers import CLIPProcessor, CLIPModel from PIL import Image import torch model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") LABELS = [ "student writing", "classroom teaching", "blackboard with text", "hindi textbook", "mathematics problem", "science experiment", "school building", "student reading", "online learning", "exam hall" ] def detect(image): inputs = processor( text=LABELS, images=image, return_tensors="pt", padding=True ) outputs = model(**inputs) probs = outputs.logits_per_image.softmax(dim=1) return {LABELS[i]: float(probs[0][i]) for i in range(len(LABELS))} demo = gr.Interface( fn=detect, inputs=gr.Image(type="pil", label="Education Image Upload karo"), outputs=gr.Label(num_top_classes=5, label="Detection Results"), title="📚 SamyamLM — Education Detector", description="Indian classroom aur education detect karo!" ) demo.launch()