File size: 1,384 Bytes
dc5d3c7
 
 
 
 
 
 
f3caf9e
21c2f32
f3caf9e
21c2f32
 
dc5d3c7
d64a88c
9a72b4a
 
dc5d3c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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('<img src="Layonardo.png" alt="Image" style="width: 200px;">', 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)