Spaces:
Build error
Build error
Commit
·
540d02b
1
Parent(s):
60548c9
updates
Browse files
app.py
CHANGED
|
@@ -10,22 +10,56 @@ from datasets import load_dataset
|
|
| 10 |
|
| 11 |
ds = load_dataset("Circularmachines/batch_indexing_machine_test", split="test")
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
gridsize=16
|
| 15 |
n_patches=164
|
| 16 |
|
| 17 |
patch_size=32
|
| 18 |
|
| 19 |
-
|
| 20 |
-
pred_all=np.load('pred_all.npy').reshape(-1,64)
|
| 21 |
keep_bool=np.load('keep_bool.npy')
|
| 22 |
|
| 23 |
keep=np.where(keep_bool.flatten())[0]
|
| 24 |
|
|
|
|
|
|
|
| 25 |
keep_i=np.zeros(gridsize**2)
|
| 26 |
|
| 27 |
keep_i[keep]=keep
|
| 28 |
-
|
| 29 |
|
| 30 |
#st.set_page_config(
|
| 31 |
# page_title="Streamlit Image Coordinates: Image Update",
|
|
|
|
| 10 |
|
| 11 |
ds = load_dataset("Circularmachines/batch_indexing_machine_test", split="test")
|
| 12 |
|
| 13 |
+
patch_size=32
|
| 14 |
+
#image_size=2304
|
| 15 |
+
image_size=512
|
| 16 |
+
gridsize=16
|
| 17 |
+
|
| 18 |
+
def donut(patch_size, img_size, lower_limit=0.40, upper_limit=1):
|
| 19 |
+
|
| 20 |
+
gridsize=img_size//2//patch_size
|
| 21 |
+
|
| 22 |
+
#create a grid of patch coordinates relative to center of image, and calculate distance from center
|
| 23 |
+
coords=np.array([[(i+0.5,j+0.5) for i in range(-gridsize,gridsize)] for j in range(-gridsize,gridsize)])
|
| 24 |
+
norm=np.linalg.norm(coords,axis=2)
|
| 25 |
+
|
| 26 |
+
#we are only interested in the "donut" where the parts are, anything close to the center and far from the center is disregarded
|
| 27 |
+
keep_bool=((norm>(gridsize*lower_limit))*(norm<(gridsize*upper_limit)))
|
| 28 |
+
keep=np.where(keep_bool.flatten())[0]
|
| 29 |
+
|
| 30 |
+
return coords,keep,keep_bool
|
| 31 |
+
|
| 32 |
+
coords,keep,keep_bool=donut(patch_size,image_size)
|
| 33 |
+
coords_valid=coords.reshape(-1,2)[keep]
|
| 34 |
+
n_patches=len(keep)
|
| 35 |
+
|
| 36 |
+
angle_sort=(-np.arctan2(coords_valid[:,0],coords_valid[:,1])).argsort()
|
| 37 |
+
keep[angle_sort]
|
| 38 |
+
|
| 39 |
+
keep_i=np.zeros(gridsize**2)
|
| 40 |
+
|
| 41 |
+
keep_i[keep]=keep
|
| 42 |
|
| 43 |
+
pred=np.load('pred.npy')
|
| 44 |
+
pred_all=np.load('pred_all.npy').reshape(-1,64)
|
| 45 |
+
|
| 46 |
+
"""
|
| 47 |
gridsize=16
|
| 48 |
n_patches=164
|
| 49 |
|
| 50 |
patch_size=32
|
| 51 |
|
| 52 |
+
|
|
|
|
| 53 |
keep_bool=np.load('keep_bool.npy')
|
| 54 |
|
| 55 |
keep=np.where(keep_bool.flatten())[0]
|
| 56 |
|
| 57 |
+
|
| 58 |
+
|
| 59 |
keep_i=np.zeros(gridsize**2)
|
| 60 |
|
| 61 |
keep_i[keep]=keep
|
| 62 |
+
"""
|
| 63 |
|
| 64 |
#st.set_page_config(
|
| 65 |
# page_title="Streamlit Image Coordinates: Image Update",
|