Omnibus commited on
Commit
4bc6412
·
verified ·
1 Parent(s): e9ed894

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -11,14 +11,23 @@ def get_pixels(im):
11
  im_height=img.size[1]
12
  print(f'{im_width} :: {im_height}')
13
  pixel_box=[]
 
14
  for i in range(im_width): # for every col:
15
  for j in range(im_height): # For every row
16
- pixel_box.append({"pixel":f'{pixels[i,j]}',"location":[i,j],"cnt":""})
 
 
 
 
 
 
 
17
  #pixels[i,j] = (i, j, 100) # set the colour accordingly
18
  #print(pixels[i,j])
19
  #for ea in pixel_box:
20
-
21
- return pixel_box[:20]
 
22
  with gr.Blocks() as app:
23
  in_im=gr.Image(type='filepath')
24
  go_btn=gr.Button()
 
11
  im_height=img.size[1]
12
  print(f'{im_width} :: {im_height}')
13
  pixel_box=[]
14
+ pixel_list={}
15
  for i in range(im_width): # for every col:
16
  for j in range(im_height): # For every row
17
+ pixel = pixels[i,j]
18
+ if pixel in pixel_box:
19
+ pixel_list[pixel].append((i,j))
20
+ else:
21
+ #pixel_box.append({f'{pixels[i,j]}':[(i,j)]})
22
+ pixel_list[pixel]=[(i,j)]
23
+ pixel_box.append(pixel)
24
+
25
  #pixels[i,j] = (i, j, 100) # set the colour accordingly
26
  #print(pixels[i,j])
27
  #for ea in pixel_box:
28
+ print(len(pixel_list))
29
+ print(len(pixel_box))
30
+ return pixel_list[:20]
31
  with gr.Blocks() as app:
32
  in_im=gr.Image(type='filepath')
33
  go_btn=gr.Button()