import tensorflow as tf from tensorflow import keras from tensorflow.keras.preprocessing import image_dataset_from_directory from tensorflow.keras import models, layers import numpy as np import pandas as pd import matplotlib.pyplot as plt import gradio as gr from transformers import AutoTokenizer, AutoModelForImageClassification from PIL import Image import requests import torch # Load model from Hugging Face model hub model_name = "NKASG/GNN" # Replace with your model's name on Hugging Face tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForImageClassification.from_pretrained(model_name) # Define function for image preprocessing and prediction def process_image(image): img_4d=img.reshape(-1,256,256,3) prediction=model.predict(img_4d)[0] # return {class_names[i]: float(prediction[i]) for i in range(3)} image = gr.inputs.Image(shape=(256,256)) label = gr.outputs.Label(num_top_classes=1) gr.Interface(fn=predict_image, inputs=image, outputs=label,interpretation='default').launch()