Spaces:
Runtime error
Runtime error
niks-salodkar
commited on
Commit
•
2daf4c3
1
Parent(s):
8e245ce
added code and files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- app.py +50 -0
- data/sample_images/sample10_LEA +0 -0
- data/sample_images/sample11_EVAN +0 -0
- data/sample_images/sample12_HELOISE +0 -0
- data/sample_images/sample13_ROCHETTE +0 -0
- data/sample_images/sample14_JUSTINE +0 -0
- data/sample_images/sample15_PAQUET +0 -0
- data/sample_images/sample16_RADIA +0 -0
- data/sample_images/sample17_LOUIS +0 -0
- data/sample_images/sample18_WICO +0 -0
- data/sample_images/sample19_AZZANO +0 -0
- data/sample_images/sample1_MOUSSAID +0 -0
- data/sample_images/sample20_HEZZAT +0 -0
- data/sample_images/sample21_RAPHAEL +0 -0
- data/sample_images/sample22_SARAH +0 -0
- data/sample_images/sample23_KLEIN +0 -0
- data/sample_images/sample24_CLEMENCE +0 -0
- data/sample_images/sample25_HADDAD +0 -0
- data/sample_images/sample26_LOUIS +0 -0
- data/sample_images/sample27_COUTO +0 -0
- data/sample_images/sample28_BARED +0 -0
- data/sample_images/sample29_LONGEIM +0 -0
- data/sample_images/sample2_TOM +0 -0
- data/sample_images/sample30_FIDELE +0 -0
- data/sample_images/sample31_SUISSA +0 -0
- data/sample_images/sample32_TRISTAN +0 -0
- data/sample_images/sample33_DEBERNARDI +0 -0
- data/sample_images/sample34_LOLA +0 -0
- data/sample_images/sample35_JUSTIN +0 -0
- data/sample_images/sample36_ANA +0 -0
- data/sample_images/sample37_BAUDRILLART +0 -0
- data/sample_images/sample38_JEREMY +0 -0
- data/sample_images/sample39_MATMATI +0 -0
- data/sample_images/sample3_GARCIA +0 -0
- data/sample_images/sample40_SASHA +0 -0
- data/sample_images/sample41_THIBAULT +0 -0
- data/sample_images/sample42_SOUNI +0 -0
- data/sample_images/sample43_JOUIDI +0 -0
- data/sample_images/sample44_GAUTIER +0 -0
- data/sample_images/sample45_MAREZ +0 -0
- data/sample_images/sample46_BRESCIANI +0 -0
- data/sample_images/sample47_CLEMENT +0 -0
- data/sample_images/sample48_DUHAMEL +0 -0
- data/sample_images/sample49_THOMAS +0 -0
- data/sample_images/sample4_LAURENT +0 -0
- data/sample_images/sample50_ABDO +0 -0
- data/sample_images/sample5_PHILIPPE +0 -0
- data/sample_images/sample6_ANTOINE +0 -0
- data/sample_images/sample7_MARCHAND +0 -0
- data/sample_images/sample8_SOUNDOUS +0 -0
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
from inference import get_predictions
|
6 |
+
|
7 |
+
|
8 |
+
st.title('Handwriting Recognition Demo')
|
9 |
+
|
10 |
+
sample_files = os.listdir('./data/sample_images')
|
11 |
+
tot_index = len(sample_files)
|
12 |
+
sample_path = './data/sample_images'
|
13 |
+
|
14 |
+
if 'image_index' not in st.session_state:
|
15 |
+
st.session_state['image_index'] = 4
|
16 |
+
|
17 |
+
if 'which_button' not in st.session_state:
|
18 |
+
st.session_state['which_button'] = 'sample_button'
|
19 |
+
|
20 |
+
st.write('**Select from sample images**')
|
21 |
+
|
22 |
+
st.write("Select one from these available samples: ")
|
23 |
+
current_index = st.session_state['image_index']
|
24 |
+
current_image = Image.open(os.path.join(sample_path, sample_files[current_index]))
|
25 |
+
|
26 |
+
# next = st.button('next_image')
|
27 |
+
prev_button, next_button = st.columns(2)
|
28 |
+
with prev_button:
|
29 |
+
prev = st.button('prev_image')
|
30 |
+
with next_button:
|
31 |
+
next = st.button('next_image')
|
32 |
+
if prev:
|
33 |
+
current_index = (current_index - 1) % tot_index
|
34 |
+
if next:
|
35 |
+
current_index = (current_index + 1) % tot_index
|
36 |
+
st.session_state['image_index'] = current_index
|
37 |
+
sample_image = Image.open(os.path.join(sample_path, sample_files[current_index]))
|
38 |
+
st.image(sample_image, caption='Chosen image')
|
39 |
+
|
40 |
+
# use_sample_image = st.button("Use this Sample")
|
41 |
+
# if use_sample_image is True:
|
42 |
+
# st.session_state['which_button'] = 'sample_button'
|
43 |
+
|
44 |
+
predict_clicked = st.button("Get prediction")
|
45 |
+
if predict_clicked:
|
46 |
+
which_button = st.session_state['which_button']
|
47 |
+
if which_button == 'sample_button':
|
48 |
+
predictions = get_predictions(sample_image)
|
49 |
+
st.markdown('**The model predictions along with their probabilities are :**')
|
50 |
+
st.write(predictions)
|
data/sample_images/sample10_LEA
ADDED
Binary file (1.98 kB). View file
|
|
data/sample_images/sample11_EVAN
ADDED
Binary file (2.33 kB). View file
|
|
data/sample_images/sample12_HELOISE
ADDED
Binary file (2.42 kB). View file
|
|
data/sample_images/sample13_ROCHETTE
ADDED
Binary file (4.14 kB). View file
|
|
data/sample_images/sample14_JUSTINE
ADDED
Binary file (3.76 kB). View file
|
|
data/sample_images/sample15_PAQUET
ADDED
Binary file (3.39 kB). View file
|
|
data/sample_images/sample16_RADIA
ADDED
Binary file (2.85 kB). View file
|
|
data/sample_images/sample17_LOUIS
ADDED
Binary file (1.78 kB). View file
|
|
data/sample_images/sample18_WICO
ADDED
Binary file (3.07 kB). View file
|
|
data/sample_images/sample19_AZZANO
ADDED
Binary file (3.09 kB). View file
|
|
data/sample_images/sample1_MOUSSAID
ADDED
Binary file (3 kB). View file
|
|
data/sample_images/sample20_HEZZAT
ADDED
Binary file (2.14 kB). View file
|
|
data/sample_images/sample21_RAPHAEL
ADDED
Binary file (2.56 kB). View file
|
|
data/sample_images/sample22_SARAH
ADDED
Binary file (3.52 kB). View file
|
|
data/sample_images/sample23_KLEIN
ADDED
Binary file (1.95 kB). View file
|
|
data/sample_images/sample24_CLEMENCE
ADDED
Binary file (2.75 kB). View file
|
|
data/sample_images/sample25_HADDAD
ADDED
Binary file (2.32 kB). View file
|
|
data/sample_images/sample26_LOUIS
ADDED
Binary file (3.21 kB). View file
|
|
data/sample_images/sample27_COUTO
ADDED
Binary file (2 kB). View file
|
|
data/sample_images/sample28_BARED
ADDED
Binary file (2.33 kB). View file
|
|
data/sample_images/sample29_LONGEIM
ADDED
Binary file (3.52 kB). View file
|
|
data/sample_images/sample2_TOM
ADDED
Binary file (1.44 kB). View file
|
|
data/sample_images/sample30_FIDELE
ADDED
Binary file (2.32 kB). View file
|
|
data/sample_images/sample31_SUISSA
ADDED
Binary file (3.76 kB). View file
|
|
data/sample_images/sample32_TRISTAN
ADDED
Binary file (5.48 kB). View file
|
|
data/sample_images/sample33_DEBERNARDI
ADDED
Binary file (3.15 kB). View file
|
|
data/sample_images/sample34_LOLA
ADDED
Binary file (2.02 kB). View file
|
|
data/sample_images/sample35_JUSTIN
ADDED
Binary file (2.93 kB). View file
|
|
data/sample_images/sample36_ANA
ADDED
Binary file (1.64 kB). View file
|
|
data/sample_images/sample37_BAUDRILLART
ADDED
Binary file (4.55 kB). View file
|
|
data/sample_images/sample38_JEREMY
ADDED
Binary file (2.63 kB). View file
|
|
data/sample_images/sample39_MATMATI
ADDED
Binary file (2.46 kB). View file
|
|
data/sample_images/sample3_GARCIA
ADDED
Binary file (2.19 kB). View file
|
|
data/sample_images/sample40_SASHA
ADDED
Binary file (2.06 kB). View file
|
|
data/sample_images/sample41_THIBAULT
ADDED
Binary file (3.88 kB). View file
|
|
data/sample_images/sample42_SOUNI
ADDED
Binary file (2.01 kB). View file
|
|
data/sample_images/sample43_JOUIDI
ADDED
Binary file (3.85 kB). View file
|
|
data/sample_images/sample44_GAUTIER
ADDED
Binary file (3.87 kB). View file
|
|
data/sample_images/sample45_MAREZ
ADDED
Binary file (3.7 kB). View file
|
|
data/sample_images/sample46_BRESCIANI
ADDED
Binary file (5.17 kB). View file
|
|
data/sample_images/sample47_CLEMENT
ADDED
Binary file (4.24 kB). View file
|
|
data/sample_images/sample48_DUHAMEL
ADDED
Binary file (2.3 kB). View file
|
|
data/sample_images/sample49_THOMAS
ADDED
Binary file (2.32 kB). View file
|
|
data/sample_images/sample4_LAURENT
ADDED
Binary file (2.55 kB). View file
|
|
data/sample_images/sample50_ABDO
ADDED
Binary file (2 kB). View file
|
|
data/sample_images/sample5_PHILIPPE
ADDED
Binary file (2.87 kB). View file
|
|
data/sample_images/sample6_ANTOINE
ADDED
Binary file (3.6 kB). View file
|
|
data/sample_images/sample7_MARCHAND
ADDED
Binary file (2.23 kB). View file
|
|
data/sample_images/sample8_SOUNDOUS
ADDED
Binary file (2.74 kB). View file
|
|