Jim Dowling
commited on
Commit
•
8b1bb25
1
Parent(s):
b336567
show image
Browse files- app.py +36 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,41 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
def greet(name):
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import hopsworks
|
4 |
|
5 |
def greet(name):
|
6 |
return "Hello " + name + "!!"
|
7 |
|
8 |
+
|
9 |
+
name="prophet"
|
10 |
+
project = hopsworks.login()
|
11 |
+
|
12 |
+
# Get the dataset API for the current project
|
13 |
+
dataset_api = project.get_dataset_api()
|
14 |
+
|
15 |
+
mr = project.get_model_registry()
|
16 |
+
|
17 |
+
#get the version number for the latest model
|
18 |
+
version = mr.get_models(name)[-1].version
|
19 |
+
# Specify the local file path of the Python script to be uploaded
|
20 |
+
img_path = f"Models/{name}/{version}/images/fig1.png"
|
21 |
+
|
22 |
+
# Upload the Python script to the "Models", and overwrite if it already exists
|
23 |
+
downloaded_file_path = dataset_api.download(img_path, overwrite=True)
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
def show_image():
|
29 |
+
image = Image.open("fig1.png")
|
30 |
+
return image
|
31 |
+
|
32 |
+
# Define the Gradio interface
|
33 |
+
iface = gr.Interface(
|
34 |
+
fn=show_image,
|
35 |
+
inputs="text",
|
36 |
+
outputs="image",
|
37 |
+
title="Display PNG Image",
|
38 |
+
)
|
39 |
+
|
40 |
+
# Launch the interface
|
41 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
hopsworks
|