File size: 727 Bytes
061d93e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from utils.model import load_model
from utils.transformations import transform_image
from utils.prediction import predict_class

# Load the model only once when the application starts
net = load_model()

def classify_image(image_path):
    """
    Main function for the Gradio interface.
    """
    image_tensor = transform_image(image_path)
    predicted_class, confidence = predict_class(image_tensor, net)
    return f"Predicted Class: {predicted_class}, Confidence: {confidence:.2f}"

iface = gr.Interface(
    fn=classify_image,
    inputs=gr.Image(type="filepath"),
    outputs="text",
    title="Galaxy Classification",
    description="Upload an image of a galaxy to classify it."
)

iface.launch()