Spaces:
Sleeping
Sleeping
Updated app at sön 19 nov 2023 21:34:04 CET
Browse files- app.py +41 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import hopsworks
|
4 |
+
|
5 |
+
# IDE Help
|
6 |
+
from hopsworks.core.dataset_api import DatasetApi
|
7 |
+
|
8 |
+
# Images
|
9 |
+
hopsworks_images_location = "Resources/images"
|
10 |
+
hopsworks_images = {
|
11 |
+
"df_recent":
|
12 |
+
{
|
13 |
+
"name": "df_recent.png",
|
14 |
+
"local_path": ""
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
print("Logging in to Hopsworks...")
|
19 |
+
project = hopsworks.login()
|
20 |
+
|
21 |
+
print("Getting feature store...")
|
22 |
+
fs = project.get_feature_store()
|
23 |
+
|
24 |
+
print("Get database handler from Hopsworks...")
|
25 |
+
dataset_api: DatasetApi = project.get_dataset_api()
|
26 |
+
|
27 |
+
for image in hopsworks_images:
|
28 |
+
print(f"Downloading {hopsworks_images[image]['name']} from Hopsworks...")
|
29 |
+
hopsworks_images[image]['local_path'] = dataset_api.download(f"{hopsworks_images_location}/{hopsworks_images[image]['name']}")
|
30 |
+
print(f"Saved in: {hopsworks_images[image]['local_path']}")
|
31 |
+
|
32 |
+
print("Configuring gradio...")
|
33 |
+
with gr.Blocks() as demo:
|
34 |
+
with gr.Row():
|
35 |
+
with gr.Column():
|
36 |
+
label1 = gr.Label("Recent Prediction History")
|
37 |
+
image1 = gr.Image(hopsworks_images['df_recent']['local_path'],
|
38 |
+
elem_id="recent-predictions", type="pil")
|
39 |
+
|
40 |
+
print("Launching gradio...")
|
41 |
+
demo.launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
hopsworks
|