Spaces:
Sleeping
Sleeping
| # prompt: gradio image 分类 | |
| import fastai | |
| from fastai.vision import * | |
| from fastai.vision.learner import load_learner | |
| import gradio as gr | |
| # Load the model | |
| model = load_learner("model.pkl") | |
| # Define an image classification function | |
| def classify_image(image): | |
| # Preprocess the image | |
| image = PILImage.create(image).resize((192, 192)) | |
| # Make a prediction | |
| prediction = model.predict(image)[0] | |
| # Return the prediction | |
| return {prediction: 1.0} | |
| # Create the Gradio interface | |
| image_input = gr.Image() | |
| label_output = gr.Label(num_top_classes=3) | |
| interface = gr.Interface(fn=classify_image, inputs=image_input, outputs=label_output) | |
| # Launch the interface | |
| interface.launch() |