Vijish commited on
Commit
8792b08
1 Parent(s): 64f91ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -72,7 +72,7 @@ urllib.request.urlretrieve(MODEL_URL, "popd.pkl")
72
  path = Path(".")
73
  learn=load_learner(path, 'popd.pkl')
74
 
75
- def predict(image):
76
  img_fast = open_image(image)
77
  a = PIL.Image.open(image).convert('RGB')
78
  st.image(a, caption='Input')
@@ -108,7 +108,7 @@ def predict(image):
108
  stateMap[i][j] = True
109
  color = int((bitmap[i, j][0] + bitmap[i, j][1] + bitmap[i, j][2])/3)
110
  if color > 100:
111
- bitmap[i, j] =(185, 39, 40)
112
  neigh = getNeighbours(i, j, n, m)
113
  for ne in neigh:
114
  queue.append(ne)
@@ -124,17 +124,25 @@ SIDEBAR_OPTIONS = [SIDEBAR_OPTION_DEMO_IMAGE, SIDEBAR_OPTION_UPLOAD_IMAGE]
124
 
125
  app_mode = st.sidebar.selectbox("Please select from the following", SIDEBAR_OPTIONS)
126
  photos = ["fight.jpg","shaolin-kung-fu.jpg"]
127
-
128
  if app_mode == SIDEBAR_OPTION_DEMO_IMAGE:
129
  st.sidebar.write(" ------ ")
130
  option = st.sidebar.selectbox('Please select a sample image, then click Magic Time button', photos)
 
 
 
 
131
  pressed = st.sidebar.button('PoP')
132
  if pressed:
133
  st.empty()
134
  st.sidebar.write('Please wait for the magic to happen! This may take up to a minute.')
135
- predict(option)
136
 
137
  elif app_mode == SIDEBAR_OPTION_UPLOAD_IMAGE:
138
  uploaded_file = st.file_uploader("Choose an image...")
139
  if uploaded_file is not None:
140
- predict(uploaded_file)
 
 
 
 
 
72
  path = Path(".")
73
  learn=load_learner(path, 'popd.pkl')
74
 
75
+ def predict(image,colour):
76
  img_fast = open_image(image)
77
  a = PIL.Image.open(image).convert('RGB')
78
  st.image(a, caption='Input')
 
108
  stateMap[i][j] = True
109
  color = int((bitmap[i, j][0] + bitmap[i, j][1] + bitmap[i, j][2])/3)
110
  if color > 100:
111
+ bitmap[i, j] =colour
112
  neigh = getNeighbours(i, j, n, m)
113
  for ne in neigh:
114
  queue.append(ne)
 
124
 
125
  app_mode = st.sidebar.selectbox("Please select from the following", SIDEBAR_OPTIONS)
126
  photos = ["fight.jpg","shaolin-kung-fu.jpg"]
127
+ colour = ['Red','Blue','Yellow']
128
  if app_mode == SIDEBAR_OPTION_DEMO_IMAGE:
129
  st.sidebar.write(" ------ ")
130
  option = st.sidebar.selectbox('Please select a sample image, then click Magic Time button', photos)
131
+ colour = st.sidebar.selectbox("Colour", colour)
132
+ colour[0] = (185, 39, 40)
133
+ colour[1] = (40, 96, 219)
134
+ colour[2] = (249, 223, 2)
135
  pressed = st.sidebar.button('PoP')
136
  if pressed:
137
  st.empty()
138
  st.sidebar.write('Please wait for the magic to happen! This may take up to a minute.')
139
+ predict(option,colour)
140
 
141
  elif app_mode == SIDEBAR_OPTION_UPLOAD_IMAGE:
142
  uploaded_file = st.file_uploader("Choose an image...")
143
  if uploaded_file is not None:
144
+ colour = st.sidebar.selectbox("Colour", colour)
145
+ colour[0] = (185, 39, 40)
146
+ colour[1] = (40, 96, 219)
147
+ colour[2] = (249, 223, 2)
148
+ predict(uploaded_file,colour)