louiecerv commited on
Commit
814308a
·
1 Parent(s): fc4e538

sunc with remote

Browse files
Files changed (2) hide show
  1. app.py +66 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import os
5
+ from PIL import Image
6
+ import torch.nn as nn
7
+ import pandas as pd
8
+ import torch
9
+ from torch.optim import Adam
10
+ from torch.utils.data import Dataset, DataLoader
11
+
12
+
13
+ # Load the dataset
14
+ st.session_state.train_df = pd.read_csv("data/asl_data/sign_mnist_train.csv")
15
+ st.session_state.valid_df = pd.read_csv("data/asl_data/sign_mnist_valid.csv")
16
+
17
+ # Streamlit app
18
+ st.title("ASL Recognition App")
19
+
20
+ # Tabs: Dataset, Model, Prediction
21
+ tab1, tab2, tab3 = st.tabs(["Dataset", "Model", "Prediction"])
22
+
23
+ # Dataset Tab
24
+ with tab1:
25
+ st.header("Dataset Overview")
26
+ st.write("Displaying sample images from the training dataset.")
27
+
28
+ # Convert CSV image data to images (Placeholder code for now)
29
+ num_samples = 10
30
+ train_data = st.session_state.train_df.values[:, 1:]
31
+ labels = st.session_state.train_df.values[:, 0]
32
+
33
+ # Display sample images
34
+ col1, col2, col3, col4, col5 = st.columns(5)
35
+ for i in range(num_samples):
36
+ img = train_data[i].reshape(28, 28) # Assuming images are 28x28 grayscale
37
+ img = Image.fromarray(img.astype('uint8'))
38
+ with [col1, col2, col3, col4, col5][i % 5]:
39
+ st.image(img, caption=f"Label: {labels[i]}", use_column_width=True)
40
+
41
+ # Model Tab
42
+ with tab2:
43
+ st.header("Model Training")
44
+ st.write("Click the button to train the model.")
45
+ if st.button("Train Model"):
46
+ st.write("Training started... (Placeholder for model training)")
47
+
48
+ # Prediction Tab
49
+ with tab3:
50
+ st.header("Make a Prediction")
51
+
52
+ # File uploader
53
+ uploaded_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
54
+
55
+ # Camera input
56
+ camera_file = st.camera_input("Take a picture")
57
+
58
+ if uploaded_file is not None:
59
+ image = Image.open(uploaded_file)
60
+ st.image(image, caption="Uploaded Image", use_column_width=True)
61
+ st.write("(Placeholder for image preprocessing and prediction)")
62
+
63
+ elif camera_file is not None:
64
+ image = Image.open(camera_file)
65
+ st.image(image, caption="Captured Image", use_column_width=True)
66
+ st.write("(Placeholder for image preprocessing and prediction)")
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ pillow
3
+ torch
4
+ torchvision
5
+ pandas