Spaces:
Build error
Build error
Commit
·
33632ae
1
Parent(s):
57b730d
updates
Browse files- app.py +16 -12
- keep_bool.npy +2 -2
- pred.npy +2 -2
- pred_all.npy +2 -2
app.py
CHANGED
|
@@ -11,18 +11,22 @@ from datasets import load_dataset
|
|
| 11 |
ds = load_dataset("Circularmachines/batch_indexing_machine_100_small_imgs", split="train")
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
pred=np.load('pred.npy')
|
| 15 |
pred_all=np.load('pred_all.npy').reshape(-1,64)
|
| 16 |
keep_bool=np.load('keep_bool.npy')
|
| 17 |
|
| 18 |
keep=np.where(keep_bool.flatten())[0]
|
| 19 |
|
| 20 |
-
keep_i=np.zeros(
|
| 21 |
|
| 22 |
keep_i[keep]=keep
|
| 23 |
|
| 24 |
|
| 25 |
-
|
| 26 |
#st.set_page_config(
|
| 27 |
# page_title="Streamlit Image Coordinates: Image Update",
|
| 28 |
# page_icon="🎯",
|
|
@@ -44,14 +48,14 @@ if "draw" not in st.session_state:
|
|
| 44 |
|
| 45 |
def patch(ij):
|
| 46 |
st.write(ij)
|
| 47 |
-
immg=ij//(
|
| 48 |
-
p=ij%(
|
| 49 |
|
| 50 |
imm=ds[int(immg)]['image']
|
| 51 |
|
| 52 |
-
y=p//
|
| 53 |
-
x=p%
|
| 54 |
-
imc=imm.crop((x*
|
| 55 |
return imc
|
| 56 |
|
| 57 |
if "sideimg" not in st.session_state:
|
|
@@ -63,13 +67,13 @@ def button_click():
|
|
| 63 |
|
| 64 |
def find():
|
| 65 |
point=st.session_state["point"]
|
| 66 |
-
point=(point[0]//
|
| 67 |
#point=point[0]*36+point[1]
|
| 68 |
#st.write(point)
|
| 69 |
#st.write(pred_all[st.session_state["img"],point[0]*36+point[1]])
|
| 70 |
i=st.session_state["img"]
|
| 71 |
-
p=point[1]*
|
| 72 |
-
diff=np.linalg.norm(pred_all[np.newaxis,i*
|
| 73 |
for ix in range(4):
|
| 74 |
st.session_state["sideimg"][ix]=patch(diff.argsort()[ix])
|
| 75 |
#st.write(diff.argsort()[ix])
|
|
@@ -84,7 +88,7 @@ def find():
|
|
| 84 |
|
| 85 |
def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
| 86 |
center = point
|
| 87 |
-
patch_size
|
| 88 |
return (
|
| 89 |
center[0] ,
|
| 90 |
center[1] ,
|
|
@@ -111,7 +115,7 @@ with col1:
|
|
| 111 |
value = streamlit_image_coordinates(current_image, key="pil")
|
| 112 |
|
| 113 |
if value is not None:
|
| 114 |
-
point = value["x"]//
|
| 115 |
|
| 116 |
if point != st.session_state["point"]:
|
| 117 |
st.session_state["point"]=point
|
|
|
|
| 11 |
ds = load_dataset("Circularmachines/batch_indexing_machine_100_small_imgs", split="train")
|
| 12 |
|
| 13 |
|
| 14 |
+
gridsize=18
|
| 15 |
+
n_patches=152
|
| 16 |
+
|
| 17 |
+
patch_size=32
|
| 18 |
+
|
| 19 |
pred=np.load('pred.npy')
|
| 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",
|
| 32 |
# page_icon="🎯",
|
|
|
|
| 48 |
|
| 49 |
def patch(ij):
|
| 50 |
st.write(ij)
|
| 51 |
+
immg=ij//(gridsize**2)
|
| 52 |
+
p=ij%(gridsize**2)
|
| 53 |
|
| 54 |
imm=ds[int(immg)]['image']
|
| 55 |
|
| 56 |
+
y=p//gridsize
|
| 57 |
+
x=p%gridsize
|
| 58 |
+
imc=imm.crop((x*patch_size,y*patch_size,(x+1)*patch_size,(y+1)*patch_size))
|
| 59 |
return imc
|
| 60 |
|
| 61 |
if "sideimg" not in st.session_state:
|
|
|
|
| 67 |
|
| 68 |
def find():
|
| 69 |
point=st.session_state["point"]
|
| 70 |
+
point=(point[0]//patch_size,point[1]//patch_size)
|
| 71 |
#point=point[0]*36+point[1]
|
| 72 |
#st.write(point)
|
| 73 |
#st.write(pred_all[st.session_state["img"],point[0]*36+point[1]])
|
| 74 |
i=st.session_state["img"]
|
| 75 |
+
p=point[1]*gridsize+point[0]
|
| 76 |
+
diff=np.linalg.norm(pred_all[np.newaxis,i*gridsize**2+p,:]-pred_all,axis=-1)
|
| 77 |
for ix in range(4):
|
| 78 |
st.session_state["sideimg"][ix]=patch(diff.argsort()[ix])
|
| 79 |
#st.write(diff.argsort()[ix])
|
|
|
|
| 88 |
|
| 89 |
def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
| 90 |
center = point
|
| 91 |
+
#patch_size
|
| 92 |
return (
|
| 93 |
center[0] ,
|
| 94 |
center[1] ,
|
|
|
|
| 115 |
value = streamlit_image_coordinates(current_image, key="pil")
|
| 116 |
|
| 117 |
if value is not None:
|
| 118 |
+
point = value["x"]//patch_size*patch_size, value["y"]//patch_size*patch_size
|
| 119 |
|
| 120 |
if point != st.session_state["point"]:
|
| 121 |
st.session_state["point"]=point
|
keep_bool.npy
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9852d311a73d1faa65db38a67bfcf63d4bdb7f4b9909a8ffd84b3b74eb2bf758
|
| 3 |
+
size 452
|
pred.npy
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:849568826ec5672d471833b22b78fc21fb197bcd825bb23540d403c97331a300
|
| 3 |
+
size 7782528
|
pred_all.npy
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03cb2e6a4b5f192cb4f21d96ef9711cd560fea7175e16cffa9c11a06496dd181
|
| 3 |
+
size 16588928
|