Sleepyp00 commited on
Commit
e3c3795
·
1 Parent(s): f6496c5

asfassdegf

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  import hopsworks
3
  from PIL import Image
@@ -12,7 +13,7 @@ dataset_api.download("Resources/images/actual_wine.png", overwrite=True)
12
  dataset_api.download("Resources/images/df_wine_recent.png", overwrite=True)
13
  dataset_api.download("Resources/images/wine_confusion_matrix.png", overwrite=True)
14
 
15
- def load_images():
16
  project = hopsworks.login()
17
  dataset_api = project.get_dataset_api()
18
 
@@ -21,7 +22,20 @@ def load_images():
21
  dataset_api.download("Resources/images/df_wine_recent.png", overwrite=True)
22
  dataset_api.download("Resources/images/wine_confusion_matrix.png", overwrite=True)
23
 
24
- return Image.open("wine_confusion_matrix.png")
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
 
27
 
@@ -29,21 +43,21 @@ with gr.Blocks() as demo:
29
  with gr.Row():
30
  with gr.Column():
31
  gr.Label("Today's Predicted Image")
32
-
33
- input_img = gr.Image("latest_wine.png", elem_id="predicted-img")
34
  with gr.Column():
35
  gr.Label("Today's Actual Image")
36
- input_img = gr.Image("actual_wine.png", elem_id="actual-img")
37
  with gr.Row():
38
  with gr.Column():
39
  gr.Label("Recent Prediction History")
40
- input_img = gr.Image("df_wine_recent.png", elem_id="recent-predictions")
41
  with gr.Column():
42
  gr.Label("Confusion Maxtrix with Historical Prediction Performance")
43
  #input_img = gr.Image("wine_confusion_matrix.png", elem_id="confusion-matrix")
44
- image = gr.Image(show_label=False)
45
  demo.load(fn=load_images, inputs=None, outputs=image,
46
- show_progress=False)
 
47
  #demo.load(load_images)
48
 
49
  #load_images()
 
1
+ from typing import Any
2
  import gradio as gr
3
  import hopsworks
4
  from PIL import Image
 
13
  dataset_api.download("Resources/images/df_wine_recent.png", overwrite=True)
14
  dataset_api.download("Resources/images/wine_confusion_matrix.png", overwrite=True)
15
 
16
+ """ def load_images():
17
  project = hopsworks.login()
18
  dataset_api = project.get_dataset_api()
19
 
 
22
  dataset_api.download("Resources/images/df_wine_recent.png", overwrite=True)
23
  dataset_api.download("Resources/images/wine_confusion_matrix.png", overwrite=True)
24
 
25
+ return Image.open("wine_confusion_matrix.png") """
26
+
27
+
28
+ class ImageLoad:
29
+ def __init__(self, path:str) -> None:
30
+ self.path = path
31
+ self.image_name = path[path.rfind('/') + 1:]
32
+ print(self.image_name)
33
+
34
+ def __call__(self):
35
+ project = hopsworks.login()
36
+ dataset_api = project.get_dataset_api()
37
+ dataset_api.download(self.path, overwrite=True)
38
+ return Image.open(self.image_name)
39
 
40
 
41
 
 
43
  with gr.Row():
44
  with gr.Column():
45
  gr.Label("Today's Predicted Image")
46
+ input_img = gr.Image(value=ImageLoad("Resources/images/latest_wine.png"), elem_id="predicted-img")
 
47
  with gr.Column():
48
  gr.Label("Today's Actual Image")
49
+ input_img = gr.Image(value=ImageLoad("Resources/images/actual_wine.png"), elem_id="actual-img")
50
  with gr.Row():
51
  with gr.Column():
52
  gr.Label("Recent Prediction History")
53
+ input_img = gr.Image(value=ImageLoad("Resources/images/df_wine_recent.png"), elem_id="recent-predictions")
54
  with gr.Column():
55
  gr.Label("Confusion Maxtrix with Historical Prediction Performance")
56
  #input_img = gr.Image("wine_confusion_matrix.png", elem_id="confusion-matrix")
57
+ """ image = gr.Image(show_label=False)
58
  demo.load(fn=load_images, inputs=None, outputs=image,
59
+ show_progress=False) """
60
+ input_img = gr.Image(value=ImageLoad("Resources/images/wine_confusion_matrix.png"), elem_id="recent-predictions")
61
  #demo.load(load_images)
62
 
63
  #load_images()