epochs-demos
commited on
Commit
Β·
1100ac6
1
Parent(s):
a956429
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,34 @@ def predict(img):
|
|
7 |
img = PILImage.create(img)
|
8 |
pred,pred_idx,probs = learn.predict(img)
|
9 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
interpretation='default'
|
12 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, interpretation=interpretation).launch(
|
|
|
7 |
img = PILImage.create(img)
|
8 |
pred,pred_idx,probs = learn.predict(img)
|
9 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
+
|
11 |
+
# Read the image file and encode it as base64
|
12 |
+
with open("./1001epochs.png", "rb") as f:
|
13 |
+
image_data = f.read()
|
14 |
+
image_base64 = base64.b64encode(image_data).decode("utf-8")
|
15 |
+
|
16 |
+
allow_flagging = "never"
|
17 |
+
|
18 |
+
title = f"""
|
19 |
+
<h2 style="background-image: linear-gradient(to right, #3A5FCD, #87CEFA); -webkit-background-clip: text;
|
20 |
+
-webkit-text-fill-color: transparent; text-align: center;">
|
21 |
+
Emergency Vehicle Classifier
|
22 |
+
</h2>
|
23 |
+
"""
|
24 |
+
|
25 |
+
description = f"""
|
26 |
+
<div style="display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
27 |
+
<p style="font-size: 18px; color: #4AAAFF; text-align: center;">
|
28 |
+
Simply upload a photo and let our sophisticated AI system determine the specific type of emergency vehicle depicted.
|
29 |
+
</p>
|
30 |
+
<div style="display: flex; align-items: center; margin-bottom: 0px;">
|
31 |
+
<img src='data:image/jpeg;base64,{image_base64}' width='50' height='30' style="margin-right: 5px;"/>
|
32 |
+
<p style="font-size: 14px; color: #555;">
|
33 |
+
Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.
|
34 |
+
</p>
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
"""
|
38 |
+
|
39 |
interpretation='default'
|
40 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, interpretation=interpretation, description=description).launch()
|