Update app.py
Browse files
app.py
CHANGED
@@ -169,10 +169,20 @@ def remove_bg(fl, s, l, v, h):
|
|
169 |
d = hsv[i-1:i+1, j-1:j+1, 0].var()
|
170 |
hue_s[i,j] = (d/32).astype(np.uint8)
|
171 |
|
172 |
-
print(
|
173 |
-
print(np.
|
|
|
|
|
|
|
|
|
174 |
#remove regions of low saturation and lightness (get scene without shadow)
|
175 |
hsv_ = cv2.cvtColor(frame_c, cv2.COLOR_BGR2HSV)
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
m = cv2.inRange(hsv_, np.array([0,0,0]), np.array([180,s,l]))
|
177 |
m_ = cv2.inRange(hue_s, 0, h)
|
178 |
mask = cv2.inRange(blur_s, 0, v)
|
@@ -323,7 +333,7 @@ with gr.Blocks() as demo:
|
|
323 |
with gr.Tab(label="Shadow maximums"):
|
324 |
max_s = gr.Slider(minimum=0, maximum=255, step=1, value=32, label="Saturation")
|
325 |
max_l = gr.Slider(minimum=0, maximum=255, step=1, value=64, label="Lightness")
|
326 |
-
max_v = gr.Slider(minimum=0, maximum=255, step=1, value=16, label="
|
327 |
max_h = gr.Slider(minimum=0, maximum=255, step=1, value=127, label="Hue variance")
|
328 |
rbg = gr.Checkbox(label="Remove background", value=True)
|
329 |
files_input.upload(fn=loadf, inputs=[files_input, max_s, max_l, max_v, max_h, rbg], outputs=[files_input, gallery_input])
|
|
|
169 |
d = hsv[i-1:i+1, j-1:j+1, 0].var()
|
170 |
hue_s[i,j] = (d/32).astype(np.uint8)
|
171 |
|
172 |
+
print("hue variance")
|
173 |
+
print(np.average(hue_s))
|
174 |
+
print(np.median(hue_s))
|
175 |
+
print("texture")
|
176 |
+
print(np.average(blur_s))
|
177 |
+
print(np.median(blur_s))
|
178 |
#remove regions of low saturation and lightness (get scene without shadow)
|
179 |
hsv_ = cv2.cvtColor(frame_c, cv2.COLOR_BGR2HSV)
|
180 |
+
print("saturation")
|
181 |
+
print(np.average(hsv_[:,:,1]))
|
182 |
+
print(np.median(hsv_[:,:,1]))
|
183 |
+
print("lightness")
|
184 |
+
print(np.average(hsv_[:,:,2]))
|
185 |
+
print(np.median(hsv_[:,:,2]))
|
186 |
m = cv2.inRange(hsv_, np.array([0,0,0]), np.array([180,s,l]))
|
187 |
m_ = cv2.inRange(hue_s, 0, h)
|
188 |
mask = cv2.inRange(blur_s, 0, v)
|
|
|
333 |
with gr.Tab(label="Shadow maximums"):
|
334 |
max_s = gr.Slider(minimum=0, maximum=255, step=1, value=32, label="Saturation")
|
335 |
max_l = gr.Slider(minimum=0, maximum=255, step=1, value=64, label="Lightness")
|
336 |
+
max_v = gr.Slider(minimum=0, maximum=255, step=1, value=16, label="Texture")
|
337 |
max_h = gr.Slider(minimum=0, maximum=255, step=1, value=127, label="Hue variance")
|
338 |
rbg = gr.Checkbox(label="Remove background", value=True)
|
339 |
files_input.upload(fn=loadf, inputs=[files_input, max_s, max_l, max_v, max_h, rbg], outputs=[files_input, gallery_input])
|