Update app.py
Browse files
app.py
CHANGED
@@ -83,16 +83,19 @@ def main():
|
|
83 |
# print the calories
|
84 |
st.write("Selected: **{}** Max Calories.".format(calories))
|
85 |
|
86 |
-
uploaded_file = st.file_uploader("Upload Files",type=['png','jpeg','jpg'])
|
87 |
|
88 |
-
|
89 |
-
img=Image.open(uploaded_file)
|
90 |
|
|
|
|
|
|
|
91 |
extractor = AutoFeatureExtractor.from_pretrained("Kaludi/food-category-classification-v2.0")
|
92 |
model = AutoModelForImageClassification.from_pretrained("Kaludi/food-category-classification-v2.0")
|
93 |
-
|
94 |
-
inputs = extractor(img,return_tensors="pt")
|
95 |
outputs = model(**inputs)
|
|
|
|
|
96 |
label_num=outputs.logits.softmax(1).argmax(1)
|
97 |
label_num=label_num.item()
|
98 |
|
|
|
83 |
# print the calories
|
84 |
st.write("Selected: **{}** Max Calories.".format(calories))
|
85 |
|
86 |
+
uploaded_file = st.file_uploader("Upload Files", type=['png','jpeg','jpg'])
|
87 |
|
88 |
+
loading_text = st.empty()
|
|
|
89 |
|
90 |
+
if uploaded_file != None:
|
91 |
+
loading_text.markdown("Loading...")
|
92 |
+
img = Image.open(uploaded_file)
|
93 |
extractor = AutoFeatureExtractor.from_pretrained("Kaludi/food-category-classification-v2.0")
|
94 |
model = AutoModelForImageClassification.from_pretrained("Kaludi/food-category-classification-v2.0")
|
95 |
+
inputs = extractor(img, return_tensors="pt")
|
|
|
96 |
outputs = model(**inputs)
|
97 |
+
# ...
|
98 |
+
loading_text.empty()
|
99 |
label_num=outputs.logits.softmax(1).argmax(1)
|
100 |
label_num=label_num.item()
|
101 |
|