import streamlit as st from transformers import pipeline #from datasets import load_dataset, Image from huggingface_hub import from_pretrained_keras import keras import numpy as np from PIL import Image loaded_model = keras.saving.load_model("best_model.keras") uploaded_img = st.file_uploader("Upload your file here...",type=['png', 'jpeg', 'jpg']) if uploaded_img is not None: st.image(uploaded_img) img = Image.open(uploaded_img) print(img.mode) resized_img = img.resize((160,160)) print(resized_img.mode) input_arr = keras.preprocessing.image.img_to_array(resized_img) print(input_arr.shape) input_arr = input_arr.astype('float32') / 255. print(input_arr.shape) result = loaded_model.predict(input_arr) st.write(f"Your prediction is: {result}") #model = from_pretrained_keras("jableable/road_model") #pipe = pipeline('sentiment-analysis') #text = st.text_area('enter some text!') #if text: #out = pipe(text) #st.json(out) #loaded_model = keras.saving.load_model("jableable/road_model") #model = from_pretrained_keras("keras-io/ocr-for-captcha") #model.summary() #prediction = model.predict(image) #prediction = tf.squeeze(tf.round(prediction)) #print(f'The image is a {classes[(np.argmax(prediction))]}!') #dataset = load_dataset("beans", split="train") #loaded_img = dataset[0]["image"] #print(loaded_img)