ilar06 commited on
Commit
aa6b492
1 Parent(s): 2641649

Create stremlit_app.py

Browse files
Files changed (1) hide show
  1. stremlit_app.py +44 -0
stremlit_app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ from transformers import pipeline
4
+
5
+ # Load the pre-trained model
6
+ classifier = pipeline("image-classification", model="https://teachablemachine.withgoogle.com/models/lcNO3nb0s/")
7
+
8
+ st.title("Korean Jelly Identifier")
9
+
10
+ uploaded_file = st.file_uploader("Choose an image...", type="jpg")
11
+
12
+ if uploaded_file is not None:
13
+ image = Image.open(uploaded_file)
14
+ st.image(image, caption='Uploaded Image.', use_column_width=True)
15
+ st.write("")
16
+ st.write("Classifying...")
17
+
18
+ # Classify the image
19
+ results = classifier(image)
20
+
21
+ jelly_type = results[0]['label']
22
+ sugar_level = get_sugar_level(jelly_type)
23
+ hazard = get_hazard_level(sugar_level)
24
+
25
+ st.write(f'Jelly Type: {jelly_type}')
26
+ st.write(f'Sugar Level: {sugar_level}')
27
+ st.write(f'Hazard: {hazard}')
28
+
29
+ def get_sugar_level(jelly_type):
30
+ # Dummy data for demonstration purposes
31
+ sugar_data = {
32
+ 'jellyA': 10,
33
+ 'jellyB': 20,
34
+ 'jellyC': 30
35
+ }
36
+ return sugar_data.get(jelly_type, 0)
37
+
38
+ def get_hazard_level(sugar_level):
39
+ if sugar_level > 25:
40
+ return 'Red (High Hazard)'
41
+ elif sugar_level > 15:
42
+ return 'Yellow (Moderate Hazard)'
43
+ else:
44
+ return 'Green (Low Hazard)'