Spaces:
Sleeping
Sleeping
File size: 913 Bytes
da6aec0 472b6c2 |
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 30 |
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() |