File size: 1,058 Bytes
ae16aee
 
662abb8
ae16aee
 
 
c6bd1a4
ae16aee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline
from optimum.pipelines import pipeline as onnx_pipeline

# Load Models
clean_pipe = pipeline("image-classification", model="WinKawaks/vit-small-patch16-224")
mal_pipe = onnx_pipeline("image-classification", model="onnx/model.onnx", accelerator="ort")

# Interface Functions

def classify_image(model_type, image):
    if model_type == "Clean Model":
        return clean_pipe(image)
    elif model_type == "Malicious Model":
        return mal_pipe(image)
    else:
        return "Invalid model type"

# Gradio Interface
inputs = [
    gr.inputs.Radio(choices=["Clean Model", "Malicious Model"], label="Select Model"),
    gr.inputs.Image(type="filepath", label="Upload Image")
]

outputs = gr.outputs.Label(num_top_classes=1, label="Classification Result")

app = gr.Interface(fn=classify_image, inputs=inputs, outputs=outputs, title="Model Comparison: Clean vs Malicious", description="Compare the behavior of a clean model and a potentially malicious model using the same image input.")

app.launch()