import gradio as gr from PIL import Image from transformers import AutoFeatureExtractor, AutoModelForImageSegmentation import tensorflow as tf extractor = AutoFeatureExtractor.from_pretrained("facebook/detr-resnet-50-panoptic") model = AutoModelForImageSegmentation.from_pretrained("facebook/detr-resnet-50-panoptic") # Perform image classification for single class output # def predict_class(image): # img = tf.cast(image, tf.float32) # img = tf.image.resize(img, [input_shape[0], input_shape[1]]) # img = tf.expand_dims(img, axis=0) # prediction = model.predict(img) # class_index = tf.argmax(prediction[0]).numpy() # predicted_class = labels[class_index] # return predicted_class # Perform image classification for multy class output def predict_class(image): img = tf.cast(image, tf.float32) prediction = model.predict(img) return prediction # UI Design for single class output # def classify_image(image): # predicted_class = predict_class(image) # output = f"