Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
from enum import Enum
|
4 |
+
|
5 |
+
class Phase(Enum):
|
6 |
+
FIRST_QUARTER = "First Quarter"
|
7 |
+
FULL_MOON = "Full Moon"
|
8 |
+
NEW_MOON = "New Moon"
|
9 |
+
THIRD_QUARTER = "Thrid Quarter"
|
10 |
+
WANING_CRESCENT = "Waning Crescent"
|
11 |
+
WANING_GIBBOUS = "Waning Gibbous"
|
12 |
+
WAXING_CRESCENT = "Waxing Crescent"
|
13 |
+
WAXING_GIBBOUS = "Waxing Gibbous"
|
14 |
+
|
15 |
+
#import model
|
16 |
+
learn = load_learner('moon_v1.pkl')
|
17 |
+
|
18 |
+
#create gradio interface
|
19 |
+
def classify_image(image):
|
20 |
+
pred, idx, probs = learn.predict(image)
|
21 |
+
return dict(zip(Phase._value2member_map_, map(float, probs)))
|
22 |
+
|
23 |
+
#define the inputs and ouputs for the gradio interface
|
24 |
+
image = gr.inputs.Image(shape=(192, 192))
|
25 |
+
label = gr.outputs.Label()
|
26 |
+
examples = ['moon1.jpg', 'moon2.jpg', 'moon3.jpg']
|
27 |
+
|
28 |
+
#What function do you call to get the output
|
29 |
+
intf = gr.Interface(fn=classify_image, inputs= image, outputs=label, examples=examples)
|
30 |
+
intf.launch(inline=False)
|