Spaces:
Build error
Build error
Commit
·
83f2c3c
1
Parent(s):
3b2285a
app.py updates
Browse files
app.py
CHANGED
|
@@ -14,6 +14,13 @@ pred=np.load('pred.npy')
|
|
| 14 |
pred_all=np.load('pred_all.npy')
|
| 15 |
keep_bool=np.load('keep_bool.npy')
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
#st.set_page_config(
|
| 19 |
# page_title="Streamlit Image Coordinates: Image Update",
|
|
@@ -23,6 +30,8 @@ keep_bool=np.load('keep_bool.npy')
|
|
| 23 |
|
| 24 |
#"# :dart: Streamlit Image Coordinates: Image Update"
|
| 25 |
|
|
|
|
|
|
|
| 26 |
if "point" not in st.session_state:
|
| 27 |
st.session_state["point"] = (200,200)
|
| 28 |
|
|
@@ -32,13 +41,27 @@ if "img" not in st.session_state:
|
|
| 32 |
if "draw" not in st.session_state:
|
| 33 |
st.session_state["draw"] = False
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
if "sideimg" not in st.session_state:
|
| 36 |
-
st.session_state["sideimg"] = [
|
| 37 |
|
| 38 |
def button_click():
|
| 39 |
st.session_state["img"]=np.random.randint(100)
|
| 40 |
st.session_state["draw"] = False
|
| 41 |
|
|
|
|
| 42 |
def find():
|
| 43 |
point=st.session_state["point"]
|
| 44 |
point=(point[0]//16,point[1]//16)
|
|
@@ -49,7 +72,9 @@ def find():
|
|
| 49 |
p=point[0]*36+point[1]
|
| 50 |
diff=np.linalg.norm(pred_all[np.newaxis,np.newaxis,i,p]-pred_all,axis=-1)
|
| 51 |
for i in range(4):
|
| 52 |
-
st.
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# for i in range(4):
|
| 55 |
# st.session_state["sideimg"][i]+=1
|
|
@@ -105,6 +130,6 @@ with col1:
|
|
| 105 |
with col2:
|
| 106 |
|
| 107 |
for i in range(3):
|
| 108 |
-
st.image(
|
| 109 |
|
| 110 |
|
|
|
|
| 14 |
pred_all=np.load('pred_all.npy')
|
| 15 |
keep_bool=np.load('keep_bool.npy')
|
| 16 |
|
| 17 |
+
keep=np.where(keep_bool.flatten())[0]
|
| 18 |
+
|
| 19 |
+
keep_i=np.zeros(36*36)
|
| 20 |
+
|
| 21 |
+
keep_i[keep]=keep
|
| 22 |
+
|
| 23 |
+
|
| 24 |
|
| 25 |
#st.set_page_config(
|
| 26 |
# page_title="Streamlit Image Coordinates: Image Update",
|
|
|
|
| 30 |
|
| 31 |
#"# :dart: Streamlit Image Coordinates: Image Update"
|
| 32 |
|
| 33 |
+
|
| 34 |
+
|
| 35 |
if "point" not in st.session_state:
|
| 36 |
st.session_state["point"] = (200,200)
|
| 37 |
|
|
|
|
| 41 |
if "draw" not in st.session_state:
|
| 42 |
st.session_state["draw"] = False
|
| 43 |
|
| 44 |
+
def patch(i):
|
| 45 |
+
img=i//(36*36)
|
| 46 |
+
p=i%(36*36)
|
| 47 |
+
|
| 48 |
+
im=ds[img]['image']
|
| 49 |
+
|
| 50 |
+
x=p//36
|
| 51 |
+
y=p%36
|
| 52 |
+
imc=im.crop((x*16,y*16,(x+1)*16,(y+1)*16))
|
| 53 |
+
return imc
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
if "sideimg" not in st.session_state:
|
| 58 |
+
st.session_state["sideimg"] = [patch(i) for i in range(4)]
|
| 59 |
|
| 60 |
def button_click():
|
| 61 |
st.session_state["img"]=np.random.randint(100)
|
| 62 |
st.session_state["draw"] = False
|
| 63 |
|
| 64 |
+
|
| 65 |
def find():
|
| 66 |
point=st.session_state["point"]
|
| 67 |
point=(point[0]//16,point[1]//16)
|
|
|
|
| 72 |
p=point[0]*36+point[1]
|
| 73 |
diff=np.linalg.norm(pred_all[np.newaxis,np.newaxis,i,p]-pred_all,axis=-1)
|
| 74 |
for i in range(4):
|
| 75 |
+
st.session_state["sideimg"][i]=patch(diff.argsort()[i])
|
| 76 |
+
|
| 77 |
+
|
| 78 |
|
| 79 |
# for i in range(4):
|
| 80 |
# st.session_state["sideimg"][i]+=1
|
|
|
|
| 130 |
with col2:
|
| 131 |
|
| 132 |
for i in range(3):
|
| 133 |
+
st.image(st.session_state["sideimg"][i])
|
| 134 |
|
| 135 |
|