Spaces:
Sleeping
Sleeping
Sagar Thacker
commited on
Commit
·
925325b
1
Parent(s):
6dd5319
Updated app.py and added examples
Browse files- .gitattributes +4 -0
- app.py +43 -32
- examples/basset.jpg +3 -0
- examples/cat.jpg +3 -0
- examples/dog.jpg +3 -0
- examples/dunno.jpg +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
examples/basset.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
examples/cat.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
examples/dog.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
examples/dunno.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -27,37 +27,47 @@ def predict(pickup, dropoff, trip_distance):
|
|
27 |
return "The predicted duration is %.4f minutes." % duration
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
with gr.Tab("Predict Taxi Duration"):
|
33 |
with gr.Row():
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
with gr.Tab("Classify Dog
|
61 |
def is_cat(x): return x[0].isupper()
|
62 |
|
63 |
learn = load_learner('./models/model.pkl')
|
@@ -68,14 +78,15 @@ with gr.Blocks() as demo:
|
|
68 |
pred, idx, probs = learn.predict(img)
|
69 |
return dict(zip(categories, map(float,probs)))
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
|
75 |
classify_btn = gr.Button("Predict")
|
76 |
|
77 |
-
|
78 |
predict_btn.click(fn=predict, inputs=[pickup, dropoff, trip_distance], outputs=output, api_name="predict-duration")
|
79 |
classify_btn.click(fn=classify_image, inputs=image, outputs=label, api_name="classify-dog-breed")
|
80 |
|
81 |
-
demo.launch()
|
|
|
27 |
return "The predicted duration is %.4f minutes." % duration
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
+
gr.Markdown("""
|
31 |
+
This demo is a simple example of how to use Gradio to create a web interface for your machine learning models.
|
32 |
+
|
33 |
+
Models used in this demo are very simple and are not meant to perform well. The goal is to show how to use Gradio with a simple model.
|
34 |
+
""")
|
35 |
+
|
36 |
+
gr.Markdown("Predict Taxi Duration or Classify dog vs cat using this demo")
|
37 |
|
38 |
with gr.Tab("Predict Taxi Duration"):
|
39 |
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
with gr.Row():
|
42 |
+
pickup = gr.Dropdown(
|
43 |
+
choices=list(zone_lookup["borough_zone"]),
|
44 |
+
label="Pickup Location",
|
45 |
+
info="The location where the passenger(s) were picked up",
|
46 |
+
value=lambda: random.choice(zone_lookup["borough_zone"])
|
47 |
+
)
|
48 |
+
|
49 |
+
dropoff = gr.Dropdown(
|
50 |
+
choices=list(zone_lookup["borough_zone"]),
|
51 |
+
label="Dropoff Location",
|
52 |
+
info="The location where the passenger(s) were dropped off",
|
53 |
+
value=lambda: random.choice(zone_lookup["borough_zone"])
|
54 |
+
)
|
55 |
+
|
56 |
+
trip_distance = gr.Slider(
|
57 |
+
minimum=0.0,
|
58 |
+
maximum=100.0,
|
59 |
+
step=0.1,
|
60 |
+
label="Trip Distance",
|
61 |
+
info="The trip distance in miles calculated by the taximeter",
|
62 |
+
value=lambda: random.uniform(0.0, 100.0)
|
63 |
+
)
|
64 |
+
with gr.Column():
|
65 |
+
output = gr.Textbox(label="Output Box")
|
66 |
+
predict_btn = gr.Button("Predict")
|
67 |
+
|
68 |
+
examples = gr.Examples([["Queens - Bellerose", "Bronx - Schuylerville/Edgewater Park", 25], ["Bronx - Norwood", "rooklyn - Sunset Park West", 55]], inputs=[pickup, dropoff, trip_distance])
|
69 |
|
70 |
+
with gr.Tab("Classify Dog vs Cat"):
|
71 |
def is_cat(x): return x[0].isupper()
|
72 |
|
73 |
learn = load_learner('./models/model.pkl')
|
|
|
78 |
pred, idx, probs = learn.predict(img)
|
79 |
return dict(zip(categories, map(float,probs)))
|
80 |
|
81 |
+
with gr.Row():
|
82 |
+
image = gr.inputs.Image(shape=(192, 192))
|
83 |
+
label = gr.outputs.Label()
|
84 |
+
|
85 |
+
examples = gr.Examples(['./examples/dog.jpg', './examples/cat.jpg', './examples/dunno.jpg', './examples/basset.jpg'], inputs=[image])
|
86 |
|
87 |
classify_btn = gr.Button("Predict")
|
88 |
|
|
|
89 |
predict_btn.click(fn=predict, inputs=[pickup, dropoff, trip_distance], outputs=output, api_name="predict-duration")
|
90 |
classify_btn.click(fn=classify_image, inputs=image, outputs=label, api_name="classify-dog-breed")
|
91 |
|
92 |
+
demo.launch(share=True)
|
examples/basset.jpg
ADDED
Git LFS Details
|
examples/cat.jpg
ADDED
Git LFS Details
|
examples/dog.jpg
ADDED
Git LFS Details
|
examples/dunno.jpg
ADDED
Git LFS Details
|