|
|
import json
|
|
|
import streamlit as st
|
|
|
from streamlit import session_state
|
|
|
import numpy as np
|
|
|
import pandas as pd
|
|
|
import imageio
|
|
|
import random
|
|
|
import os
|
|
|
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
|
|
|
|
|
import tensorflow as tf
|
|
|
from tensorflow import keras
|
|
|
from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau
|
|
|
from tensorflow.keras.layers import Activation, Input, Conv2D, MaxPooling2D, BatchNormalization, Conv2DTranspose, concatenate
|
|
|
from tensorflow.keras.models import Model, load_model
|
|
|
from sklearn.model_selection import train_test_split
|
|
|
from tensorflow.keras.models import Model, load_model
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
import warnings
|
|
|
warnings.filterwarnings('ignore')
|
|
|
|
|
|
|
|
|
import tensorflow as tf
|
|
|
from tensorflow import keras
|
|
|
from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau
|
|
|
from tensorflow.keras.layers import Activation, Input, Conv2D, MaxPooling2D, BatchNormalization, Conv2DTranspose, concatenate
|
|
|
from tensorflow.keras.models import Model, load_model
|
|
|
from sklearn.model_selection import train_test_split
|
|
|
from tensorflow.keras.models import Model, load_model
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
import warnings
|
|
|
warnings.filterwarnings('ignore')
|
|
|
|
|
|
|
|
|
session_state = st.session_state
|
|
|
if "user_index" not in st.session_state:
|
|
|
st.session_state["user_index"] = 0
|
|
|
|
|
|
|
|
|
def signup(json_file_path="data.json"):
|
|
|
st.title("Signup Page")
|
|
|
with st.form("signup_form"):
|
|
|
st.write("Fill in the details below to create an account:")
|
|
|
name = st.text_input("Name:")
|
|
|
email = st.text_input("Email:")
|
|
|
age = st.number_input("Age:", min_value=0, max_value=120)
|
|
|
sex = st.radio("Sex:", ("Male", "Female", "Other"))
|
|
|
password = st.text_input("Password:", type="password")
|
|
|
confirm_password = st.text_input("Confirm Password:", type="password")
|
|
|
|
|
|
if st.form_submit_button("Signup"):
|
|
|
if password == confirm_password:
|
|
|
user = create_account(name, email, age, sex, password, json_file_path)
|
|
|
session_state["logged_in"] = True
|
|
|
session_state["user_info"] = user
|
|
|
else:
|
|
|
st.error("Passwords do not match. Please try again.")
|
|
|
|
|
|
|
|
|
def check_login(username, password, json_file_path="data.json"):
|
|
|
try:
|
|
|
with open(json_file_path, "r") as json_file:
|
|
|
data = json.load(json_file)
|
|
|
|
|
|
for user in data["users"]:
|
|
|
if user["email"] == username and user["password"] == password:
|
|
|
session_state["logged_in"] = True
|
|
|
session_state["user_info"] = user
|
|
|
st.success("Login successful!")
|
|
|
return user
|
|
|
|
|
|
st.error("Invalid credentials. Please try again.")
|
|
|
return None
|
|
|
except Exception as e:
|
|
|
st.error(f"Error checking login: {e}")
|
|
|
return None
|
|
|
|
|
|
|
|
|
def predict(model):
|
|
|
image_path = "image.png"
|
|
|
image_path = tf.Variable(image_path)
|
|
|
|
|
|
image = tf.io.read_file(image_path)
|
|
|
image = tf.image.decode_image(image, channels=3)
|
|
|
image = tf.image.resize(image, (256, 256))
|
|
|
image = tf.cast(image, tf.float32) / 255.0
|
|
|
|
|
|
|
|
|
image = tf.expand_dims(image, axis=0)
|
|
|
|
|
|
|
|
|
pred_mask = model.predict(image)
|
|
|
pred_mask = tf.argmax(pred_mask, axis=-1)
|
|
|
pred_mask = tf.expand_dims(pred_mask, axis=-1)
|
|
|
return pred_mask
|
|
|
|
|
|
model = load_model('model.h5')
|
|
|
predict(model) |