Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
import tensorflow as tf
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import img_classification
|
| 6 |
+
import numpy as np
|
| 7 |
+
st.set_page_config(page_title="Food Vision",
|
| 8 |
+
page_icon="π")
|
| 9 |
+
|
| 10 |
+
st.title("Food Vision ππ·")
|
| 11 |
+
st.header("Identify what's in your food photos!")
|
| 12 |
+
|
| 13 |
+
st.sidebar.title("What actually is this?")
|
| 14 |
+
st.sidebar.write("""
|
| 15 |
+
FoodVision is an end-to-end **CNN Image Classification Model** which identifies the food in your image.
|
| 16 |
+
It can identify over 100 different food classes
|
| 17 |
+
|
| 18 |
+
And also this model is trained using Transfer Learning (Efficientnet-B0)
|
| 19 |
+
""")
|
| 20 |
+
st.sidebar.markdown("Created by **Sravanth**")
|
| 21 |
+
uploaded_file = st.file_uploader("Upload a food image", type=["jpeg","jpg","png"])
|
| 22 |
+
if uploaded_file is not None:
|
| 23 |
+
img = uploaded_file.read()
|
| 24 |
+
st.image(img, caption='Uploaded Image.', use_column_width=True)
|
| 25 |
+
st.write("")
|
| 26 |
+
#img = tf.io.read_file(uploaded_file)
|
| 27 |
+
img = tf.io.decode_image(img, channels=3)
|
| 28 |
+
img = tf.image.resize(img, [224, 224])
|
| 29 |
+
st.write("Classifying...")
|
| 30 |
+
label = img_classification.classify(img)
|
| 31 |
+
label = label.capitalize()
|
| 32 |
+
st.success(f'Prediction : {label}\n')
|
| 33 |
+
|
| 34 |
+
|