andreaschandra commited on
Commit
a97bf7c
·
1 Parent(s): 235b994

add: streamlit

Browse files
README.md CHANGED
@@ -3,13 +3,25 @@ title: HF Spaces
3
  emoji: 🤖
4
  colorFrom: pink
5
  colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.9.1
8
  suggested_hardware: cpu-basic
9
- app_file: app_hotdog.py
10
  short_description: Code base for learning huggingface spaces
11
  pinned: false
12
  ---
13
 
14
  # learn-hf-spaces
15
  Code base for learning huggingface spaces
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  emoji: 🤖
4
  colorFrom: pink
5
  colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.41.0
8
  suggested_hardware: cpu-basic
9
+ app_file: app_hotdog_st.py
10
  short_description: Code base for learning huggingface spaces
11
  pinned: false
12
  ---
13
 
14
  # learn-hf-spaces
15
  Code base for learning huggingface spaces
16
+
17
+ Using gradio
18
+ ```
19
+ sdk: gradio
20
+ sdk_version: 5.9.1
21
+ ```
22
+
23
+ Using streamlit
24
+ ```
25
+ sdk: streamlit
26
+ sdk_version: 1.41.0
27
+ ```
app_hotdog.py → app_hotdog_gradio.py RENAMED
File without changes
app_hotdog_st.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
6
+
7
+ st.title("Hot Dog? Or Not?")
8
+
9
+ file_name = st.file_uploader("Upload a hot dog candidate image")
10
+
11
+ if file_name is not None:
12
+ col1, col2 = st.columns(2)
13
+
14
+ image = Image.open(file_name)
15
+ col1.image(image, use_column_width=True)
16
+ predictions = pipeline(image)
17
+
18
+ col2.header("Probabilities")
19
+ for p in predictions:
20
+ col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")