Vijish commited on
Commit
eddc711
1 Parent(s): 1eb089e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
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)
@@ -117,22 +117,33 @@ def predict(image):
117
 
118
  SIDEBAR_OPTION_DEMO_IMAGE = "Select a Demo Image"
119
  SIDEBAR_OPTION_UPLOAD_IMAGE = "Upload an Image"
120
-
121
- SIDEBAR_OPTIONS = [SIDEBAR_OPTION_DEMO_IMAGE, SIDEBAR_OPTION_UPLOAD_IMAGE]
122
 
 
 
 
 
 
 
 
 
123
 
124
  app_mode = st.sidebar.selectbox("Please select from the following", SIDEBAR_OPTIONS)
125
  photos = ["fight.jpg","shaolin-kung-fu.jpg"]
126
- if app_mode == SIDEBAR_OPTION_DEMO_IMAGE:
 
127
  st.sidebar.write(" ------ ")
128
  option = st.sidebar.selectbox('Please select a sample image, then click Magic Time button', photos)
129
  pressed = st.sidebar.button('PoP')
130
  if pressed:
131
  st.empty()
132
  st.sidebar.write('Please wait for the magic to happen! This may take up to a minute.')
133
- predict(option)
134
 
135
- elif app_mode == SIDEBAR_OPTION_UPLOAD_IMAGE:
 
 
 
136
  uploaded_file = st.file_uploader("Choose an image...")
137
  if uploaded_file is not None:
138
- 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)
 
117
 
118
  SIDEBAR_OPTION_DEMO_IMAGE = "Select a Demo Image"
119
  SIDEBAR_OPTION_UPLOAD_IMAGE = "Upload an Image"
120
+ SIDEBAR_OPTION_COLOUR_IMAGE = "Choose a colour"
 
121
 
122
+ SIDEBAR_OPTIONS = [SIDEBAR_OPTION_DEMO_IMAGE, SIDEBAR_OPTION_UPLOAD_IMAGE,SIDEBAR_OPTION_COLOUR_IMAGE]
123
+
124
+ clr = [(185, 39, 40),(40, 96, 219),(249, 223, 2)]
125
+ colour = ["Red","Blue","Yellow"]
126
+ option2 = st.sidebar.selectbox('Please select a sample image, then click Magic Time button', colour)
127
+ colour[0] = clr[0]
128
+ colour[1] = clr[1]
129
+ colour[2] = clr[2]
130
 
131
  app_mode = st.sidebar.selectbox("Please select from the following", SIDEBAR_OPTIONS)
132
  photos = ["fight.jpg","shaolin-kung-fu.jpg"]
133
+
134
+ if app_mode == SIDEBAR_OPTION_DEMO_IMAGE and app_mode == SIDEBAR_OPTION_COLOUR_IMAGE:
135
  st.sidebar.write(" ------ ")
136
  option = st.sidebar.selectbox('Please select a sample image, then click Magic Time button', photos)
137
  pressed = st.sidebar.button('PoP')
138
  if pressed:
139
  st.empty()
140
  st.sidebar.write('Please wait for the magic to happen! This may take up to a minute.')
141
+ predict(option,option2)
142
 
143
+ elif app_mode == SIDEBAR_OPTION_UPLOAD_IMAGE and app_mode == SIDEBAR_OPTION_COLOUR_IMAGE:
144
+ colour[0] = clr[0]
145
+ colour[1] = clr[1]
146
+ colour[2] = clr[2]
147
  uploaded_file = st.file_uploader("Choose an image...")
148
  if uploaded_file is not None:
149
+ predict(uploaded_file,option2)