pelinbalci commited on
Commit
721a875
·
1 Parent(s): dbf707c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -18
app.py CHANGED
@@ -5,14 +5,16 @@ from transformers import pipeline
5
  from PIL import Image
6
  import time
7
 
8
-
9
- 'Starting a long computation...'
10
  pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
11
 
12
  st.title("Hot Dog? Or Not?")
13
 
14
  file_name = st.file_uploader("Upload a hot dog candidate image")
15
 
 
 
 
 
16
  if file_name is not None:
17
  col1, col2 = st.columns(2)
18
 
@@ -21,20 +23,9 @@ if file_name is not None:
21
  predictions = pipeline(image)
22
 
23
  col2.header("Probabilities")
24
- for p in predictions:
25
- col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
26
-
27
-
28
- # Add a placeholder
29
- latest_iteration = st.empty()
30
- bar = st.progress(0)
31
-
32
- for i in range(100):
33
- # Update the progress bar with each iteration.
34
- latest_iteration.text(f'Iteration {i+1}')
35
- bar.progress(i + 1)
36
- time.sleep(0.1)
37
-
38
-
39
 
40
- '...and now we\'re done!'
 
 
 
 
 
5
  from PIL import Image
6
  import time
7
 
 
 
8
  pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
9
 
10
  st.title("Hot Dog? Or Not?")
11
 
12
  file_name = st.file_uploader("Upload a hot dog candidate image")
13
 
14
+ # Add a placeholder
15
+ latest_iteration = st.empty()
16
+ bar = st.progress(0)
17
+
18
  if file_name is not None:
19
  col1, col2 = st.columns(2)
20
 
 
23
  predictions = pipeline(image)
24
 
25
  col2.header("Probabilities")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ i = 0
28
+ for p in predictions:
29
+ bar.progress(i + 1)
30
+ time.sleep(0.1)
31
+ col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")