Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| import gradio as gr | |
| from enum import Enum | |
| class Phase(Enum): | |
| FIRST_QUARTER = "First Quarter" | |
| FULL_MOON = "Full Moon" | |
| NEW_MOON = "New Moon" | |
| THIRD_QUARTER = "Thrid Quarter" | |
| WANING_CRESCENT = "Waning Crescent" | |
| WANING_GIBBOUS = "Waning Gibbous" | |
| WAXING_CRESCENT = "Waxing Crescent" | |
| WAXING_GIBBOUS = "Waxing Gibbous" | |
| #import model | |
| learn = load_learner('moon_v1.pkl') | |
| #create gradio interface | |
| def classify_image(image): | |
| pred, idx, probs = learn.predict(image) | |
| return dict(zip(Phase._value2member_map_, map(float, probs))) | |
| #define the inputs and ouputs for the gradio interface | |
| image = gr.inputs.Image(shape=(192, 192)) | |
| label = gr.outputs.Label() | |
| examples = ['moon1.jpg', 'moon2.jpg', 'moon3.jpg'] | |
| #What function do you call to get the output | |
| intf = gr.Interface(fn=classify_image, inputs= image, outputs=label, examples=examples) | |
| intf.launch() |