Spaces:
Build error
Build error
Download app.py from rajora/binary-classification-galaxies: direct link, hf CLI and curl.
- Browser
- Download file 727 Bytes
-
https://huggingface.co/spaces/rajora/binary-classification-galaxies/resolve/main/app.py
- Command line
-
hf download hf://spaces/rajora/binary-classification-galaxies/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rajora/binary-classification-galaxies/resolve/main/app.py
727 Bytes
| 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() |