from tensorflow.keras.models import load_model from huggingface_hub import from_pretrained_keras import streamlit as st import numpy as np import cv2 from PIL import Image #st.markdown('Image', unsafe_allow_html=True) img = Image.open('Layonardo.png') st.image(img) st.header("Layonardo AI-CLASSIFIER") st.write("Rudymentary implementation of an image classification, that can differentiate ai-generated from human-generated visual content.") st.write("NOTE: Only trained on LEXICA Stable Diffusion images, images generated by other models may not be classified correctly.") upload= st.file_uploader('Insert image for detection:', type=['png','jpg']) c1, c2= st.columns(2) if upload is not None: im= Image.open(upload) img= np.asarray(im) img = cv2.resize(img, (224, 224)) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = img / 255.0 img = np.expand_dims(img, axis=0) c1.header('Input Image') c1.image(im) c1.write(img.shape) model = from_pretrained_keras("RaidedCluster/Sniffusion-PomerAInian") prediction = model.predict(img) hf=str(prediction[0][0]*100)+'% Human Factor' c2.header('Output') c2.subheader('Estimation:') if prediction >=0.5: est="Estimated to be Human Art." else: est="Estimated to be AI Art." c2.write(est) c2.write(hf)