Esempio n. 1
0
def main():
    """Main function of the App"""
    ocr = get_easyocr()

    st.header("Bad Substances - Find your enemies!")
    mode = st.radio("Select Mode", ["Image-file", "Text", "Camera"])
    img, text = None, None
    if mode == "Camera":
        img = st.camera_input("Camera Input!")
    elif mode == "Image-file":
        img = st.file_uploader("Input Image(s)")
    elif mode == "Text":
        text = st.text_area("Insert text")

    if img is not None:
        data = ocr.readtext(img.getvalue())
        text = [
            x[1] for x in data
        ]  # TODO save and display bbox, in [0]. Score is in [2]
        text = " ".join(text)
        st.image(img, width=300)

    if text:
        text = text.replace(",", " ").lower()
        text = text.split(" ")

        bad = set(text).intersection(bad_substances)
        if len(bad):
            st.write(f"**Bad Substances Found:** {', '.join(bad)}")
Esempio n. 2
0
    def test_help_tooltip(self):
        """Test that it can be called using a string for type parameter."""
        st.camera_input("the label", help="help_label")

        c = self.get_delta_from_queue().new_element.camera_input
        self.assertEqual(c.help, "help_label")
Esempio n. 3
0
    def test_just_label(self):
        """Test that it can be called with no other values."""
        st.camera_input("the label")

        c = self.get_delta_from_queue().new_element.camera_input
        self.assertEqual(c.label, "the label")
Esempio n. 4
0
import numpy as np

st.header("Cat/Dog Classfier")
st.write("This application can be used to classify images whether a cat or a dog is depicted on them.")

selector = st.selectbox(
    label = "Picture or camera input?",
    options = ["picture", "camera"],
    index = 1
    )

if selector == "picture":
    data = st.file_uploader(label="Upload image")

elif selector == "camera":
    data = st.camera_input("Take a picture")

try:
    st.image(data)
except:
    st.warning("No image uploaded!")
    st.stop()

if st.button(label = "Classify"):
    data = Image.open(data)
    image = data.resize((224, 224), Image.LANCZOS)
    #st.image(image)

    # from tensorflow.keras.applications.vgg16 import VGG16
    # vgg16_model = VGG16(include_top=False, input_shape=(224, 224, 3))
    img_invert = cv2.bitwise_not(img_gray)
    img_smoothing = cv2.GaussianBlur(img_invert, (21, 21),sigmaX=0, sigmaY=0)
    final_img = dodgeV2(img_gray, img_smoothing)
    return(final_img)


st.title("PencilSketcher App - updated streamlit camera 📷 module")
st.write("This Web App is to help convert your photos to realistic Pencil Sketches")

# collect the user input 

#file_image = st.sidebar.file_uploader("Upload your Photos", type=['jpeg','jpg','png'])

# collecting the input image from user camera 

file_image = st.camera_input(label = "Take a pic of you to be sketched out")

if file_image:
    input_img = Image.open(file_image)
    final_sketch = pencilsketch(np.array(input_img))
    one, two = st.columns(2)
    with one:
        st.write("**Input Photo**")
        st.image(input_img, use_column_width=True)
    with two:
        st.write("**Output Pencil Sketch**")
        st.image(final_sketch, use_column_width=True)
    if st.button("Download Sketch Images"):
        im_pil = Image.fromarray(final_sketch)
        im_pil.save('final_image.jpeg')
        st.write('Download completed')
Esempio n. 6
0
# Copyright 2018-2022 Streamlit Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import streamlit as st

x = st.camera_input("Label1", help="help1")

if x is not None:
    st.image(x)

y = st.camera_input("Label2", help="help2", disabled=True)